PreviewQuery.php 1.37 KB
<?php

namespace FootyRoom\Queries;

use Illuminate\Database\Connection;
use FootyRoom\Support\MongoClient;

class PreviewQuery
{
    /**
     * @var \FootyRoom\Support\MongoClient
     */
    protected $mongo;

    /**
     * @var \Illuminate\Database\Connection
     */
    protected $mysql;

    /**
     * Constructor.
     *
     * @param FootyRoom\Support\MongoClient $mongo
     * @param \Illuminate\Database\Connection $mysql
     */
    public function __construct(MongoClient $mongo, Connection $mysql)
    {
        $this->mongo = $mongo->footyroom;
        $this->mysql = $mysql;
    }

    /**
     * Finds one preview by matchId.
     *
     * @param int $matchId
     *
     * @return object
     */
    public function findOneByMatchId($matchId)
    {
        return $this->mongo->previews->findOne(['mysqlMatchId' => $matchId]);
    }

    /**
     * Finds preview post by match id.
     *
     * @param int $matchId
     *
     * @return object
     */
    // public function findPostByMatchId($matchId)
    // {
    //     return $this->mysql

    //     ->table('wp_posts as p')
    //     ->select('p.post_title')
    //     ->join('wp_postmeta as pm', 'pm.post_id', '=', 'p.ID')
    //     ->where('p.post_status', '=', 'publish')
    //     ->where('pm.meta_key', '=', 'match_id_preview')
    //     ->where('pm.meta_value', '=', (string) $matchId)
    //     ->first();
    // }
}