| 1 | <?php |
||
| 8 | final class TestimoniesService extends CRUDServices |
||
| 9 | { |
||
| 10 | protected Testimony $testimony; |
||
|
|
|||
| 11 | |||
| 12 | public function __construct() |
||
| 13 | { |
||
| 14 | $this->testimony = app(Testimony::class); |
||
| 15 | |||
| 16 | $testimonyId = request()->route('testimony') ?? request('testimony_id'); |
||
| 17 | |||
| 18 | if ($testimonyId) { |
||
| 19 | $this->testimony = $this->testimony->resolveRouteBinding($testimonyId); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Retrieves an instance of testimony. |
||
| 25 | * |
||
| 26 | * @return \Faithgen\Testimonies\Models\Testimony |
||
| 27 | */ |
||
| 28 | public function getTestimony(): Testimony |
||
| 29 | { |
||
| 30 | return $this->testimony; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Makes a list of fields that you do not want to be sent |
||
| 35 | * to the create or update methods. |
||
| 36 | * Its mainly the fields that you do not have in the messages table. |
||
| 37 | * |
||
| 38 | * @return array |
||
| 39 | */ |
||
| 40 | public function getUnsetFields(): array |
||
| 41 | { |
||
| 42 | return ['testimony_id']; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Attaches a parent to the current testimony |
||
| 47 | * You can delete this if you do not intent to create testimonys from parent relationships. |
||
| 48 | */ |
||
| 49 | public function getParentRelationship() |
||
| 50 | { |
||
| 51 | return auth()->user()->testimonies(); |
||
| 52 | } |
||
| 53 | } |
||
| 54 |