Files
izyim/app/Classes/Modules/Contacts/Services/ListsContact.php
T
2019-03-19 17:11:21 +08:00

40 lines
777 B
PHP
Executable File

<?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)->get();
// Return collection of contacts as a resource
return ContactResource::collection($contacts);
}
}