<?php

namespace App\Classes\Modules\Companies\Services;


use App\Models\Company;
use App\Http\Resources\Company as CompanyResource;
use Illuminate\Http\Request;

class SearchesCompany
{

    /** @var  Company */
    private $repository;

    /**
     * SearchesCompany constructor.
     * @param Company $repository
     */
    public function __construct(Company $repository)
    {
        $this->repository = $repository;
    }


    public function execute(Request $request){

        $companies = $this->repository->where('name', 'LIKE', "%".$request->input('query')."%")
            ->orWhere('marking', 'LIKE', "%".$request->input('query')."%")->paginate(10);

        return CompanyResource::collection($companies);
    }

}