Files
izyim/app/Classes/Modules/Contacts/Services/ListsContact.php
2019-05-09 12:26:14 +08:00

40 lines
806 B
PHP

<?php
/**
* Created by PhpStorm.
* User: user
* Date: 06/03/2019
* Time: 4:57 PM
*/
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);
}
}