1 | <?php namespace App\Http\Controllers; |
||
8 | class UsersController extends Controller |
||
9 | { |
||
10 | /** |
||
11 | * Create a new authentication controller instance. |
||
12 | */ |
||
13 | 13 | public function __construct() |
|
17 | |||
18 | /** |
||
19 | * Show the form for creating a new resource. |
||
20 | * |
||
21 | * @param \Illuminate\Http\Request $request |
||
22 | * |
||
23 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
24 | */ |
||
25 | 3 | public function create(Request $request) |
|
33 | |||
34 | /** |
||
35 | * Store a newly created user. |
||
36 | * |
||
37 | * @param \Illuminate\Http\Request $request |
||
38 | * @param \App\Contracts\Registrar $registrar |
||
39 | * |
||
40 | * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
||
41 | */ |
||
42 | 3 | public function store(Request $request, Registrar $registrar) |
|
43 | { |
||
44 | 3 | $user = $registrar->register(); |
|
45 | |||
46 | 1 | if ($request->ajax() || $request->wantsJson()) { |
|
47 | 1 | return response()->json($user)->setStatusCode(IlluminateResponse::HTTP_CREATED); |
|
48 | } |
||
49 | |||
50 | 1 | return redirect($this->redirectPath())->with('message', 'Created'); |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * Display the specified user information. |
||
55 | * |
||
56 | * @param \App\Contracts\Registrar $registrar |
||
57 | * @param int $id |
||
58 | * |
||
59 | * @return \Illuminate\Http\JsonResponse |
||
60 | */ |
||
61 | 2 | public function show(Registrar $registrar, $id) |
|
67 | |||
68 | /** |
||
69 | * Show the form for editing user information. |
||
70 | * |
||
71 | * @param \Illuminate\Http\Request $request |
||
72 | * @param \App\Contracts\Registrar $registrar |
||
73 | * @param int $id |
||
74 | * |
||
75 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View |
||
76 | */ |
||
77 | 1 | public function edit(Request $request, Registrar $registrar, $id) |
|
88 | |||
89 | /** |
||
90 | * Update the specified user information. |
||
91 | * |
||
92 | * @param \Illuminate\Http\Request $request |
||
93 | * @param \App\Contracts\Registrar $registrar |
||
94 | * @param int $id |
||
95 | * |
||
96 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse |
||
97 | */ |
||
98 | 2 | public function update(Request $request, Registrar $registrar, $id) |
|
107 | |||
108 | /** |
||
109 | * Remove the specified user record from storage. |
||
110 | * |
||
111 | * @param \Illuminate\Http\Request $request |
||
112 | * @param \App\Contracts\Registrar $registrar |
||
113 | * @param int $id |
||
114 | * |
||
115 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse |
||
116 | */ |
||
117 | 2 | public function destroy(Request $request, Registrar $registrar, $id) |
|
127 | |||
128 | /** |
||
129 | * Get the post register / login redirect path. |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 2 | private function redirectPath() |
|
141 | } |
||
142 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: