<?php

namespace App\Distributor\Repositories;

use App\Models\SmmPost as Model;
use Dcat\Admin\Repositories\EloquentRepository;

class SmmPost extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;


    /*
     * 插入数据
     */
    public static function create($post,$sendTime,$imageVideoUrl)
    {
        $model = new Model();
        $model->send_type = $post['send_type'];
        $model->send_time = $sendTime;
        $model->message = $post['message'];
        $model->post_type = $post['post_type'];
        $model->account_ids = implode(',',$post['account_ids']);
        $model->image_video_url = $imageVideoUrl;
        $model->status = 0;
        $model->dist_id = getDistributorId();
        $model->backup_field1 = json_encode([
            'youtube_category' => $post['youtube_category'],
        ]);
        $model->save();
        return $model->id;
    }

    /*
     * 找出状态 0 的数据
     */
    public static function getWaitPost()
    {
        $model = new Model();
        $model = $model->where('status',0)->get();
        return $model;
    }

    public static function getPostById($id)
    {
        $model = new Model();
        $model = $model->where('id',$id)->first();
        return $model;
    }




}