1 | <?php |
||
18 | class EnrollmentsController extends Controller |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * @var EnrollmentRepository |
||
23 | */ |
||
24 | protected $repository; |
||
25 | |||
26 | /** |
||
27 | * @var EnrollmentValidator |
||
28 | */ |
||
29 | protected $validator; |
||
30 | |||
31 | /** |
||
32 | * EnrollmentsController constructor. |
||
33 | * @param EnrollmentRepository $repository |
||
34 | * @param EnrollmentValidator $validator |
||
35 | */ |
||
36 | public function __construct(EnrollmentRepository $repository, EnrollmentValidator $validator) |
||
37 | { |
||
38 | $this->repository = $repository; |
||
39 | $this->validator = $validator; |
||
40 | } |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Display a listing of the resource. |
||
45 | * |
||
46 | * @return \Illuminate\Http\Response |
||
47 | */ |
||
48 | public function index(EnrollmentBrowseRequest $request) |
||
|
|||
49 | { |
||
50 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
||
51 | $enrollments = $this->repository->with(['classroom', 'course', 'study'])->all(); |
||
52 | if (request()->wantsJson()) { |
||
53 | return response()->json([ |
||
54 | 'data' => $enrollments, |
||
55 | ]); |
||
56 | } |
||
57 | |||
58 | return view('enrollment_mobile::enrollments.index', compact('enrollments')); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Store a newly created resource in storage. |
||
63 | * |
||
64 | * @param EnrollmentCreateRequest $request |
||
65 | * |
||
66 | * @return \Illuminate\Http\Response |
||
67 | */ |
||
68 | public function store(EnrollmentCreateRequest $request) |
||
96 | |||
97 | |||
98 | /** |
||
99 | * Display the specified resource. |
||
100 | * |
||
101 | * @param int $id |
||
102 | * |
||
103 | * @return \Illuminate\Http\Response |
||
104 | */ |
||
105 | public function show($id) |
||
118 | |||
119 | |||
120 | /** |
||
121 | * Show the form for editing the specified resource. |
||
122 | * |
||
123 | * @param int $id |
||
124 | * |
||
125 | * @return \Illuminate\Http\Response |
||
126 | */ |
||
127 | public function edit($id) |
||
133 | |||
134 | |||
135 | /** |
||
136 | * Update the specified resource in storage. |
||
137 | * |
||
138 | * @param EnrollmentUpdateRequest $request |
||
139 | * @param $id string |
||
140 | * |
||
141 | * @return Response |
||
142 | */ |
||
143 | public function update(EnrollmentUpdateRequest $request, $id) |
||
171 | |||
172 | |||
173 | /** |
||
174 | * Remove the specified resource from storage. |
||
175 | * |
||
176 | * @param int $id |
||
177 | * |
||
178 | * @return \Illuminate\Http\Response |
||
179 | */ |
||
180 | public function destroy(EnrollmentDeleteRequest $request, $id) |
||
193 | } |
||
194 | //TODO: Fer testos de validació enrollment_mobile i todos_Backend. mock del repository del create(crear nosalters lenrollment per fer el test). |
||
195 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.