|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Services; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\EventCategoryStoreRequest; |
|
6
|
|
|
use App\Models\EventCategory; |
|
7
|
|
|
use App\Repositories\EventCategoryRepository; |
|
8
|
|
|
use Illuminate\Support\Collection; |
|
9
|
|
|
|
|
10
|
|
|
class EventCategoryService |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
private EventCategoryRepository $eventCategoryRepository; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* EventCategoryService constructor. |
|
17
|
|
|
* |
|
18
|
|
|
* @param \App\Repositories\EventCategoryRepository $eventCategoryRepository |
|
19
|
|
|
*/ |
|
20
|
5 |
|
public function __construct( |
|
21
|
|
|
EventCategoryRepository $eventCategoryRepository |
|
22
|
|
|
) { |
|
23
|
5 |
|
$this->eventCategoryRepository = $eventCategoryRepository; |
|
24
|
5 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Create a EventCategory |
|
28
|
|
|
* |
|
29
|
|
|
* @param \App\Http\Requests\EventCategoryStoreRequest $request |
|
30
|
|
|
* |
|
31
|
|
|
* @return \App\Models\EventCategory |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function createEventCategory(EventCategoryStoreRequest $request): EventCategory |
|
34
|
|
|
{ |
|
35
|
1 |
|
$eventCategory = $this->eventCategoryRepository->store($request->all()); |
|
36
|
|
|
|
|
37
|
1 |
|
return $eventCategory; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Update the EventCategory |
|
42
|
|
|
* |
|
43
|
|
|
* @param \App\Http\Requests\EventCategoryStoreRequest $request |
|
44
|
|
|
* @param int $eventCategoryId |
|
45
|
|
|
* |
|
46
|
|
|
* @return \App\Models\EventCategory |
|
47
|
|
|
*/ |
|
48
|
1 |
|
public function updateEventCategory(EventCategoryStoreRequest $request, int $eventCategoryId): EventCategory |
|
49
|
|
|
{ |
|
50
|
1 |
|
$eventCategory = $this->eventCategoryRepository->update($request->all(), $eventCategoryId); |
|
51
|
|
|
|
|
52
|
1 |
|
return $eventCategory; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Return the EventCategory from the database |
|
57
|
|
|
* |
|
58
|
|
|
* @param int $eventCategoryId |
|
59
|
|
|
* |
|
60
|
|
|
* @return \App\Models\EventCategory |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function getById(int $eventCategoryId): EventCategory |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->eventCategoryRepository->getById($eventCategoryId); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get all the EventCategories |
|
69
|
|
|
* |
|
70
|
|
|
* @return Collection |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function getEventCategories(): Collection |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->eventCategoryRepository->getAll(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Delete the EventCategory from the database |
|
79
|
|
|
* |
|
80
|
|
|
* @param int $eventCategoryId |
|
81
|
|
|
*/ |
|
82
|
1 |
|
public function deleteEventCategory(int $eventCategoryId): void |
|
83
|
|
|
{ |
|
84
|
1 |
|
$this->eventCategoryRepository->delete($eventCategoryId); |
|
85
|
1 |
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |