@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\ClassroomRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\ClassroomValidator; |
|
14 | ||
15 | class ClassroomsController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var ClassroomRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var ClassroomValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(ClassroomRepository $repository, ClassroomValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $classrooms = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $classrooms, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::classrooms.index', compact('classrooms')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param ClassroomCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(ClassroomCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $classroom = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'Classroom created.', |
|
70 | 'data' => $classroom->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $classroom = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $classroom, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('classrooms.show', compact('classroom')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $classroom = $this->repository->find($id); |
|
122 | ||
123 | return view('classrooms.edit', compact('classroom')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param ClassroomUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(ClassroomUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $classroom = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'Classroom updated.', |
|
144 | 'data' => $classroom->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'Classroom deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'Classroom deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\CourseRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\CourseValidator; |
|
14 | ||
15 | class CoursesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var CourseRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var CourseValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(CourseRepository $repository, CourseValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $courses = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $courses, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::courses.index', compact('courses')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param CourseCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(CourseCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $course = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'Course created.', |
|
70 | 'data' => $course->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $course = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $course, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('courses.show', compact('course')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $course = $this->repository->find($id); |
|
122 | ||
123 | return view('courses.edit', compact('course')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param CourseUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(CourseUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $course = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'Course updated.', |
|
144 | 'data' => $course->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'Course deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'Course deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\EnrollmentStudySubmoduleRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\EnrollmentStudySubmoduleValidator; |
|
14 | ||
15 | class EnrollmentStudySubmodulesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var EnrollmentStudySubmoduleRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var EnrollmentStudySubmoduleValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(EnrollmentStudySubmoduleRepository $repository, EnrollmentStudySubmoduleValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $enrollmentStudySubmodules = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $enrollmentStudySubmodules, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::enrollmentStudySubmodules.index', compact('enrollmentStudySubmodules')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param EnrollmentStudySubmoduleCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(EnrollmentStudySubmoduleCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $enrollmentStudySubmodule = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'EnrollmentStudySubmodule created.', |
|
70 | 'data' => $enrollmentStudySubmodule->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $enrollmentStudySubmodule = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $enrollmentStudySubmodule, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('enrollmentStudySubmodules.show', compact('enrollmentStudySubmodule')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $enrollmentStudySubmodule = $this->repository->find($id); |
|
122 | ||
123 | return view('enrollmentStudySubmodules.edit', compact('enrollmentStudySubmodule')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param EnrollmentStudySubmoduleUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(EnrollmentStudySubmoduleUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $enrollmentStudySubmodule = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'EnrollmentStudySubmodule updated.', |
|
144 | 'data' => $enrollmentStudySubmodule->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'EnrollmentStudySubmodule deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'EnrollmentStudySubmodule deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\CycleRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\CycleValidator; |
|
14 | ||
15 | class CyclesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var CycleRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var CycleValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(CycleRepository $repository, CycleValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $cycles = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $cycles, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::cycles.index', compact('cycles')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param CycleCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(CycleCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $cycle = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'Cycle created.', |
|
70 | 'data' => $cycle->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $cycle = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $cycle, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('cycles.show', compact('cycle')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $cycle = $this->repository->find($id); |
|
122 | ||
123 | return view('cycles.edit', compact('cycle')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param CycleUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(CycleUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $cycle = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'Cycle updated.', |
|
144 | 'data' => $cycle->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'Cycle deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'Cycle deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\FamilyRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\FamilyValidator; |
|
14 | ||
15 | class FamiliesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var FamilyRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var FamilyValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(FamilyRepository $repository, FamilyValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $families = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $families, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::families.index', compact('families')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param FamilyCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(FamilyCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $family = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'Family created.', |
|
70 | 'data' => $family->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $family = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $family, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('families.show', compact('family')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $family = $this->repository->find($id); |
|
122 | ||
123 | return view('families.edit', compact('family')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param FamilyUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(FamilyUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $family = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'Family updated.', |
|
144 | 'data' => $family->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'Family deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'Family deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-197 (lines=183) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\SubmoduleTypeRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\SubmoduleTypeValidator; |
|
14 | ||
15 | class SubmoduleTypesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var SubmoduleTypeRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var SubmoduleTypeValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(SubmoduleTypeRepository $repository, SubmoduleTypeValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $submoduleTypes = $this->repository->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $submoduleTypes, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::submoduleTypes.index', compact('submoduleTypes')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param SubmoduleTypeCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(SubmoduleTypeCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $submoduleType = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'SubmoduleType created.', |
|
70 | 'data' => $submoduleType->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $submoduleType = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $submoduleType, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('submoduleTypes.show', compact('submoduleType')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $submoduleType = $this->repository->find($id); |
|
122 | ||
123 | return view('submoduleTypes.edit', compact('submoduleType')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param SubmoduleTypeUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(SubmoduleTypeUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $submoduleType = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'SubmoduleType updated.', |
|
144 | 'data' => $submoduleType->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'SubmoduleType deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'SubmoduleType deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 15-185 (lines=171) @@ | ||
12 | use Scool\EnrollmentMobile\Repositories\SubmoduleRepository; |
|
13 | use Scool\EnrollmentMobile\Validators\SubmoduleValidator; |
|
14 | ||
15 | class SubmodulesController extends Controller |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * @var SubmoduleRepository |
|
20 | */ |
|
21 | protected $repository; |
|
22 | ||
23 | /** |
|
24 | * @var SubmoduleValidator |
|
25 | */ |
|
26 | protected $validator; |
|
27 | ||
28 | public function __construct(SubmoduleRepository $repository, SubmoduleValidator $validator) |
|
29 | { |
|
30 | $this->repository = $repository; |
|
31 | $this->validator = $validator; |
|
32 | } |
|
33 | ||
34 | ||
35 | /** |
|
36 | * Display a listing of the resource. |
|
37 | * |
|
38 | * @return \Illuminate\Http\Response |
|
39 | */ |
|
40 | public function index() |
|
41 | { |
|
42 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
43 | $submodules = $this->repository->with('module')->all(); |
|
44 | ||
45 | if (request()->wantsJson()) { |
|
46 | return response()->json([ |
|
47 | 'data' => $submodules, |
|
48 | ]); |
|
49 | } |
|
50 | ||
51 | return view('enrollment_mobile::submodules.index', compact('submodules')); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Store a newly created resource in storage. |
|
56 | * |
|
57 | * @param SubmoduleCreateRequest $request |
|
58 | * |
|
59 | * @return \Illuminate\Http\Response |
|
60 | */ |
|
61 | public function store(SubmoduleCreateRequest $request) |
|
62 | { |
|
63 | try { |
|
64 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
65 | ||
66 | $submodule = $this->repository->create($request->all()); |
|
67 | ||
68 | $response = [ |
|
69 | 'message' => 'Submodule created.', |
|
70 | 'data' => $submodule->toArray(), |
|
71 | ]; |
|
72 | ||
73 | if ($request->wantsJson()) { |
|
74 | return response()->json($response); |
|
75 | } |
|
76 | ||
77 | return redirect()->back()->with('message', $response['message']); |
|
78 | } catch (ValidatorException $e) { |
|
79 | if ($request->wantsJson()) { |
|
80 | return response()->json([ |
|
81 | 'error' => true, |
|
82 | 'message' => $e->getMessageBag() |
|
83 | ]); |
|
84 | } |
|
85 | ||
86 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
87 | } |
|
88 | } |
|
89 | ||
90 | ||
91 | /** |
|
92 | * Display the specified resource. |
|
93 | * |
|
94 | * @param int $id |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function show($id) |
|
99 | { |
|
100 | $submodule = $this->repository->find($id); |
|
101 | ||
102 | if (request()->wantsJson()) { |
|
103 | return response()->json([ |
|
104 | 'data' => $submodule, |
|
105 | ]); |
|
106 | } |
|
107 | ||
108 | return view('submodules.show', compact('submodule')); |
|
109 | } |
|
110 | ||
111 | ||
112 | /** |
|
113 | * Show the form for editing the specified resource. |
|
114 | * |
|
115 | * @param int $id |
|
116 | * |
|
117 | * @return \Illuminate\Http\Response |
|
118 | */ |
|
119 | public function edit($id) |
|
120 | { |
|
121 | $submodule = $this->repository->find($id); |
|
122 | ||
123 | return view('submodules.edit', compact('submodule')); |
|
124 | } |
|
125 | ||
126 | ||
127 | /** |
|
128 | * Update the specified resource in storage. |
|
129 | * |
|
130 | * @param SubmoduleUpdateRequest $request |
|
131 | * @param string $id |
|
132 | * |
|
133 | * @return Response |
|
134 | */ |
|
135 | public function update(SubmoduleUpdateRequest $request, $id) |
|
136 | { |
|
137 | try { |
|
138 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
139 | ||
140 | $submodule = $this->repository->update($id, $request->all()); |
|
141 | ||
142 | $response = [ |
|
143 | 'message' => 'Submodule updated.', |
|
144 | 'data' => $submodule->toArray(), |
|
145 | ]; |
|
146 | ||
147 | if ($request->wantsJson()) { |
|
148 | return response()->json($response); |
|
149 | } |
|
150 | ||
151 | return redirect()->back()->with('message', $response['message']); |
|
152 | } catch (ValidatorException $e) { |
|
153 | if ($request->wantsJson()) { |
|
154 | return response()->json([ |
|
155 | 'error' => true, |
|
156 | 'message' => $e->getMessageBag() |
|
157 | ]); |
|
158 | } |
|
159 | ||
160 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
161 | } |
|
162 | } |
|
163 | ||
164 | ||
165 | /** |
|
166 | * Remove the specified resource from storage. |
|
167 | * |
|
168 | * @param int $id |
|
169 | * |
|
170 | * @return \Illuminate\Http\Response |
|
171 | */ |
|
172 | public function destroy($id) |
|
173 | { |
|
174 | $deleted = $this->repository->delete($id); |
|
175 | ||
176 | if (request()->wantsJson()) { |
|
177 | return response()->json([ |
|
178 | 'message' => 'Submodule deleted.', |
|
179 | 'deleted' => $deleted, |
|
180 | ]); |
|
181 | } |
|
182 | ||
183 | return redirect()->back()->with('message', 'Submodule deleted.'); |
|
184 | } |
|
185 | } |
|
186 |
@@ 14-196 (lines=183) @@ | ||
11 | use Scool\EnrollmentMobile\Repositories\PersonRepository; |
|
12 | use Scool\EnrollmentMobile\Validators\PersonValidator; |
|
13 | ||
14 | class PeopleController extends Controller |
|
15 | { |
|
16 | ||
17 | /** |
|
18 | * @var PersonRepository |
|
19 | */ |
|
20 | protected $repository; |
|
21 | ||
22 | /** |
|
23 | * @var PersonValidator |
|
24 | */ |
|
25 | protected $validator; |
|
26 | ||
27 | public function __construct(PersonRepository $repository, PersonValidator $validator) |
|
28 | { |
|
29 | $this->repository = $repository; |
|
30 | $this->validator = $validator; |
|
31 | } |
|
32 | ||
33 | ||
34 | /** |
|
35 | * Display a listing of the resource. |
|
36 | * |
|
37 | * @return \Illuminate\Http\Response |
|
38 | */ |
|
39 | public function index() |
|
40 | { |
|
41 | $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria')); |
|
42 | $people = $this->repository->all(); |
|
43 | ||
44 | if (request()->wantsJson()) { |
|
45 | return response()->json([ |
|
46 | 'data' => $people, |
|
47 | ]); |
|
48 | } |
|
49 | ||
50 | return view('people.index', compact('people')); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Store a newly created resource in storage. |
|
55 | * |
|
56 | * @param PersonCreateRequest $request |
|
57 | * |
|
58 | * @return \Illuminate\Http\Response |
|
59 | */ |
|
60 | public function store(PersonCreateRequest $request) |
|
61 | { |
|
62 | try { |
|
63 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE); |
|
64 | ||
65 | $person = $this->repository->create($request->all()); |
|
66 | ||
67 | $response = [ |
|
68 | 'message' => 'Person created.', |
|
69 | 'data' => $person->toArray(), |
|
70 | ]; |
|
71 | ||
72 | if ($request->wantsJson()) { |
|
73 | return response()->json($response); |
|
74 | } |
|
75 | ||
76 | return redirect()->back()->with('message', $response['message']); |
|
77 | } catch (ValidatorException $e) { |
|
78 | if ($request->wantsJson()) { |
|
79 | return response()->json([ |
|
80 | 'error' => true, |
|
81 | 'message' => $e->getMessageBag() |
|
82 | ]); |
|
83 | } |
|
84 | ||
85 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
86 | } |
|
87 | } |
|
88 | ||
89 | ||
90 | /** |
|
91 | * Display the specified resource. |
|
92 | * |
|
93 | * @param int $id |
|
94 | * |
|
95 | * @return \Illuminate\Http\Response |
|
96 | */ |
|
97 | public function show($id) |
|
98 | { |
|
99 | $person = $this->repository->find($id); |
|
100 | ||
101 | if (request()->wantsJson()) { |
|
102 | return response()->json([ |
|
103 | 'data' => $person, |
|
104 | ]); |
|
105 | } |
|
106 | ||
107 | return view('people.show', compact('person')); |
|
108 | } |
|
109 | ||
110 | ||
111 | /** |
|
112 | * Show the form for editing the specified resource. |
|
113 | * |
|
114 | * @param int $id |
|
115 | * |
|
116 | * @return \Illuminate\Http\Response |
|
117 | */ |
|
118 | public function edit($id) |
|
119 | { |
|
120 | $person = $this->repository->find($id); |
|
121 | ||
122 | return view('people.edit', compact('person')); |
|
123 | } |
|
124 | ||
125 | ||
126 | /** |
|
127 | * Update the specified resource in storage. |
|
128 | * |
|
129 | * @param PersonUpdateRequest $request |
|
130 | * @param string $id |
|
131 | * |
|
132 | * @return Response |
|
133 | */ |
|
134 | public function update(PersonUpdateRequest $request, $id) |
|
135 | { |
|
136 | try { |
|
137 | $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_UPDATE); |
|
138 | ||
139 | $person = $this->repository->update($request->all(), $id); |
|
140 | ||
141 | $response = [ |
|
142 | 'message' => 'Person updated.', |
|
143 | 'data' => $person->toArray(), |
|
144 | ]; |
|
145 | ||
146 | if ($request->wantsJson()) { |
|
147 | return response()->json($response); |
|
148 | } |
|
149 | ||
150 | return redirect()->back()->with('message', $response['message']); |
|
151 | } catch (ValidatorException $e) { |
|
152 | if ($request->wantsJson()) { |
|
153 | return response()->json([ |
|
154 | 'error' => true, |
|
155 | 'message' => $e->getMessageBag() |
|
156 | ]); |
|
157 | } |
|
158 | ||
159 | return redirect()->back()->withErrors($e->getMessageBag())->withInput(); |
|
160 | } |
|
161 | } |
|
162 | ||
163 | ||
164 | /** |
|
165 | * Remove the specified resource from storage. |
|
166 | * |
|
167 | * @param int $id |
|
168 | * |
|
169 | * @return \Illuminate\Http\Response |
|
170 | */ |
|
171 | public function destroy($id) |
|
172 | { |
|
173 | $deleted = $this->repository->delete($id); |
|
174 | ||
175 | if (request()->wantsJson()) { |
|
176 | return response()->json([ |
|
177 | 'message' => 'Person deleted.', |
|
178 | 'deleted' => $deleted, |
|
179 | ]); |
|
180 | } |
|
181 | ||
182 | return redirect()->back()->with('message', 'Person deleted.'); |
|
183 | } |
|
184 | } |
|
185 |