![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mcoil.corals.io/app/Shop/ContactInfos/Repositories/ |
<?php namespace App\Shop\ContactInfos\Repositories; use App\Shop\ContactInfos\ContactInfo; use Illuminate\Support\Collection; use Jsdecena\Baserepo\BaseRepository; use Illuminate\Database\QueryException; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Shop\ContactInfos\Repositories\Interfaces\ContactInfoRepositoryInterface; class ContactInfoRepository extends BaseRepository implements ContactInfoRepositoryInterface { /** * ContactInfoRepository constructor. * * @param ContactInfo $dummy */ public function __construct(ContactInfo $dummy) { parent::__construct($dummy); $this->model = $dummy; } /** * List all the ContactInfos * * @param string $order * @param string $sort * @param array $except * @return \Illuminate\Support\Collection */ public function listContactInfos(string $order = 'id', string $sort = 'desc', $except = []) : Collection { return $this->model->orderBy($order, $sort)->get()->except($except); } /** * Create ContactInfo * * @param array $params * * @return ContactInfo * @throws InvalidArgumentException */ public function createContactInfo(array $params) : ContactInfo { try { return ContactInfo::create($params); } catch (QueryException $e) { throw new InvalidArgumentException($e->getMessage()); } } /** * Update the dummy * * @param array $params * @return ContactInfo */ public function updateContactInfo(array $params) : ContactInfo { $dummy = $this->findContactInfoById($this->model->id); $dummy->update($params); return $dummy; } /** * @param int $id * * @return ContactInfo * @throws ModelNotFoundException */ public function findContactInfoById(int $id) : ContactInfo { try { return $this->findOneOrFail($id); } catch (ModelNotFoundException $e) { throw new ModelNotFoundException($e->getMessage()); } } /** * Delete a dummy * * @return bool */ public function deleteContactInfo() : bool { return $this->model->delete(); } /** * @param string $text * @return mixed */ public function searchContactInfo(string $text = null) : Collection { if (is_null($text)) { return $this->all(); } return $this->model->searchContactInfo($text)->get(); } }