mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-21 05:13:58 +00:00
65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: user
|
|
* Date: 25/03/2019
|
|
* Time: 10:53 AM
|
|
*/
|
|
|
|
namespace App\Classes\Modules\Orders\Services;
|
|
|
|
|
|
use App\Models\Order;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Resources\Order as OrderResource;
|
|
|
|
class SearchesOrder
|
|
{
|
|
/** @var Order */
|
|
private $repository;
|
|
|
|
/**
|
|
* SearchesOrder constructor.
|
|
* @param Order $repository
|
|
*/
|
|
public function __construct(Order $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
public function execute(Request $request,array $status)
|
|
{
|
|
|
|
$order = $this->repository;
|
|
|
|
if($request->input('marking') !== null)
|
|
{
|
|
$order = $order->where('marking','LIKE','%'.$request->input('marking').'%');
|
|
}
|
|
|
|
if($request->input('startDate') !== null)
|
|
{
|
|
$startDate = Carbon::createFromFormat('d-m-Y', $request->input('startDate'))->format('Y-m-d');
|
|
$order = $order->where('created_at', '>=', $startDate);
|
|
}
|
|
|
|
if($request->input('endDate') !== null)
|
|
{
|
|
$endDate = Carbon::createFromFormat('d-m-Y', $request->input('endDate'))->format('Y-m-d');
|
|
$order = $order->where('created_at', '<=', $endDate);
|
|
}
|
|
|
|
if(count($status))
|
|
{
|
|
$order = $order->whereIn('current_step', $status);
|
|
}
|
|
|
|
$order = $order->paginate(10);
|
|
return OrderResource::collection($order);
|
|
|
|
}
|
|
|
|
} |