Files
Omair Saleh 919e0252f7 large commit
2019-06-03 10:29:08 +08:00

34 lines
723 B
PHP

<?php
namespace App\Classes\Modules\Contacts\Services;
use App\Models\Contact;
use App\Http\Resources\Contact as ContactResource;
class ListsContact
{
/** @var Contact */
private $repository;
/**
* ListsContact constructor.
* @param Contact $repository
*/
public function __construct(Contact $repository)
{
$this->repository = $repository;
}
public function execute(int $type, int $referenceId){
$contacts = $this->repository->where('type', $type)
->where('reference_id', $referenceId)->orderBy('created_at')->paginate(5);
// Return collection of contacts as a resource
return ContactResource::collection($contacts);
}
}