1 | <?php |
||
17 | class UsersController extends AuthorizedController |
||
18 | { |
||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | protected $resource = 'users'; |
||
23 | |||
24 | /** |
||
25 | * Display a listing of the resource. |
||
26 | * |
||
27 | * @param \Cortex\Fort\DataTables\Managerarea\UsersDataTable $usersDataTable |
||
28 | * |
||
29 | * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
||
30 | */ |
||
31 | public function index(UsersDataTable $usersDataTable) |
||
38 | |||
39 | /** |
||
40 | * Get a listing of the resource logs. |
||
41 | * |
||
42 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
43 | * |
||
44 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse |
||
45 | */ |
||
46 | public function logs(UserContract $user) |
||
52 | |||
53 | /** |
||
54 | * Get a listing of the resource activities. |
||
55 | * |
||
56 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
57 | * |
||
58 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse |
||
59 | */ |
||
60 | public function activities(UserContract $user) |
||
66 | |||
67 | /** |
||
68 | * Show the form for create/update of the given resource. |
||
69 | * |
||
70 | * @param \Illuminate\Http\Request $request |
||
71 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
72 | * |
||
73 | * @return \Illuminate\Http\Response |
||
|
|||
74 | */ |
||
75 | public function form(Request $request, UserContract $user) |
||
76 | { |
||
77 | $countries = countries(); |
||
78 | $authUser = $request->user($this->getGuard()); |
||
79 | $languages = collect(languages())->pluck('name', 'iso_639_1'); |
||
80 | $genders = ['m' => trans('cortex/fort::common.male'), 'f' => trans('cortex/fort::common.female')]; |
||
81 | $owner = optional(optional(config('rinvex.tenants.active'))->owner)->id; |
||
82 | |||
83 | $roles = $authUser->isSuperadmin() || $authUser->id === $owner |
||
84 | ? app('rinvex.fort.role')->all()->pluck('name', 'id')->toArray() |
||
85 | : $authUser->roles->pluck('name', 'id')->toArray(); |
||
86 | |||
87 | $abilities = $authUser->isSuperadmin() || $authUser->id === $owner |
||
88 | ? app('rinvex.fort.role')->forAllTenants()->where('slug', 'manager')->first()->abilities->groupBy('resource')->map->pluck('name', 'id')->toArray() |
||
89 | : $authUser->allAbilities->groupBy('resource')->map->pluck('name', 'id')->toArray(); |
||
90 | |||
91 | $logs = app(LogsDataTable::class)->with(['id' => 'logs-table'])->html()->minifiedAjax(route('managerarea.users.logs', ['user' => $user])); |
||
92 | $activities = app(ActivitiesDataTable::class)->with(['id' => 'activities-table'])->html()->minifiedAjax(route('managerarea.users.activities', ['user' => $user])); |
||
93 | |||
94 | return view('cortex/fort::managerarea.pages.user', compact('user', 'abilities', 'roles', 'countries', 'languages', 'genders', 'logs', 'activities')); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Store a newly created resource in storage. |
||
99 | * |
||
100 | * @param \Cortex\Fort\Http\Requests\Managerarea\UserFormRequest $request |
||
101 | * |
||
102 | * @return \Illuminate\Http\Response |
||
103 | */ |
||
104 | public function store(UserFormRequest $request) |
||
105 | { |
||
106 | return $this->process($request, app('rinvex.fort.user')); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Update the given resource in storage. |
||
111 | * |
||
112 | * @param \Cortex\Fort\Http\Requests\Managerarea\UserFormRequest $request |
||
113 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
114 | * |
||
115 | * @return \Illuminate\Http\Response |
||
116 | */ |
||
117 | public function update(UserFormRequest $request, UserContract $user) |
||
118 | { |
||
119 | return $this->process($request, $user); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Process the form for store/update of the given resource. |
||
124 | * |
||
125 | * @param \Illuminate\Foundation\Http\FormRequest $request |
||
126 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
127 | * |
||
128 | * @return \Illuminate\Http\Response |
||
129 | */ |
||
130 | protected function process(FormRequest $request, UserContract $user) |
||
157 | |||
158 | /** |
||
159 | * Delete the given resource from storage. |
||
160 | * |
||
161 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
162 | * |
||
163 | * @return \Illuminate\Http\Response |
||
164 | */ |
||
165 | public function delete(UserContract $user) |
||
174 | |||
175 | /** |
||
176 | * Delete the given resource from storage. |
||
177 | * |
||
178 | * @param \Rinvex\Fort\Contracts\UserContract $user |
||
179 | * @param \Spatie\MediaLibrary\Models\Media $media |
||
180 | * |
||
181 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse |
||
182 | */ |
||
183 | public function deleteMedia(UserContract $user, Media $media) |
||
192 | } |
||
193 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.