<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/12/14
 * Time: 16:51
 */

namespace App\Modules\Agents\Models;

use Illuminate\Database\Eloquent\Model;
use DB;
class AgentsManage extends Model
{
    protected $table = 'agent_manage';

    public static function getSendOrdersByAgentName($agentName, $isAll = false)
    {
        $search_obj = self::join('agent_info', 'agent_manage.agent_name', '=', 'agent_info.agent_name')
            ->join('send_orders', 'agent_info.send_order_id', '=', 'send_orders.id')
            ->where('agent_manage.agent_name', '=', $agentName)
            ->whereBetween('send_orders.pre_send_date',[date('Y-m-d',strtotime('-2 day')),date('Y-m-d 23:59:59')])
            ->select('send_orders.*');
        //$search_obj=DB::table('send_orders')->   select('send_orders.*');
        return $search_obj->paginate(15);

    }

}