@@ -168,16 +168,16 @@ discard block |
||
| 168 | 168 | call_user_func($this->callback, $this); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $response = function () { |
|
| 171 | + $response = function() { |
|
| 172 | 172 | $handle = fopen('php://output', 'w'); |
| 173 | 173 | $titles = []; |
| 174 | 174 | fwrite($handle, chr(0xEF).chr(0xBB).chr(0xBF)); |
| 175 | - $this->chunk(function ($collection) use ($handle, &$titles) { |
|
| 175 | + $this->chunk(function($collection) use ($handle, &$titles) { |
|
| 176 | 176 | Column::setOriginalGridModels($collection); |
| 177 | 177 | |
| 178 | 178 | $original = $current = $collection->toArray(); |
| 179 | 179 | |
| 180 | - $this->grid->getColumns()->map(function (Column $column) use (&$current) { |
|
| 180 | + $this->grid->getColumns()->map(function(Column $column) use (&$current) { |
|
| 181 | 181 | $current = $column->fill($current); |
| 182 | 182 | $this->grid->columnNames[] = $column->getName(); |
| 183 | 183 | }); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | protected function getVisiableTitles() |
| 207 | 207 | { |
| 208 | 208 | $titles = $this->grid->visibleColumns() |
| 209 | - ->mapWithKeys(function (Column $column) { |
|
| 209 | + ->mapWithKeys(function(Column $column) { |
|
| 210 | 210 | $columnName = $column->getName(); |
| 211 | 211 | $columnTitle = $column->getLabel(); |
| 212 | 212 | if (isset($this->titleCallbacks[$columnName])) { |
@@ -240,7 +240,7 @@ |
||
| 240 | 240 | { |
| 241 | 241 | $connection = $this->model->getConnection(); |
| 242 | 242 | |
| 243 | - return $connection->getSchemaBuilder()->getColumns($connection->getTablePrefix() . $this->model->getTable()); |
|
| 243 | + return $connection->getSchemaBuilder()->getColumns($connection->getTablePrefix().$this->model->getTable()); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | return $content |
| 28 | 28 | ->title(trans('admin.menu')) |
| 29 | 29 | ->description(trans('admin.list')) |
| 30 | - ->row(function (Row $row) { |
|
| 30 | + ->row(function(Row $row) { |
|
| 31 | 31 | $row->column(6, $this->treeView()->render()); |
| 32 | 32 | |
| 33 | - $row->column(6, function (Column $column) { |
|
| 33 | + $row->column(6, function(Column $column) { |
|
| 34 | 34 | $form = new \Encore\Admin\Widgets\Form(); |
| 35 | 35 | $form->action(admin_url('auth/menu')); |
| 36 | 36 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $tree->disableCreate(); |
| 78 | 78 | |
| 79 | - $tree->branch(function ($branch) { |
|
| 79 | + $tree->branch(function($branch) { |
|
| 80 | 80 | $payload = "<i class='fa {$branch['icon']}'></i> <strong>{$branch['title']}</strong>"; |
| 81 | 81 | |
| 82 | 82 | if (!isset($branch['children'])) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $form->display('created_at', trans('admin.created_at')); |
| 139 | 139 | $form->display('updated_at', trans('admin.updated_at')); |
| 140 | 140 | |
| 141 | - $form->saved(function (Form $form) { |
|
| 141 | + $form->saved(function(Form $form) { |
|
| 142 | 142 | Admin::clearCache(); |
| 143 | 143 | }); |
| 144 | 144 | |
@@ -32,21 +32,21 @@ discard block |
||
| 32 | 32 | $grid->column('slug', trans('admin.slug')); |
| 33 | 33 | $grid->column('name', trans('admin.name')); |
| 34 | 34 | |
| 35 | - $grid->column('permissions', trans('admin.permission'))->pluck('name')->label()->display(function ($raw) { |
|
| 35 | + $grid->column('permissions', trans('admin.permission'))->pluck('name')->label()->display(function($raw) { |
|
| 36 | 36 | return str_replace(' ', '<br>', $raw); |
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | 39 | $grid->column('created_at', trans('admin.created_at')); |
| 40 | 40 | $grid->column('updated_at', trans('admin.updated_at')); |
| 41 | 41 | |
| 42 | - $grid->actions(function (Grid\Displayers\Actions $actions) { |
|
| 42 | + $grid->actions(function(Grid\Displayers\Actions $actions) { |
|
| 43 | 43 | if ($actions->row->slug == 'administrator') { |
| 44 | 44 | $actions->disableDelete(); |
| 45 | 45 | } |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | - $grid->tools(function (Grid\Tools $tools) { |
|
| 49 | - $tools->batch(function (Grid\Tools\BatchActions $actions) { |
|
| 48 | + $grid->tools(function(Grid\Tools $tools) { |
|
| 49 | + $tools->batch(function(Grid\Tools\BatchActions $actions) { |
|
| 50 | 50 | $actions->disableDelete(); |
| 51 | 51 | }); |
| 52 | 52 | }); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $show->field('id', 'ID'); |
| 71 | 71 | $show->field('slug', trans('admin.slug')); |
| 72 | 72 | $show->field('name', trans('admin.name')); |
| 73 | - $show->field('permissions', trans('admin.permissions'))->as(function ($permission) { |
|
| 73 | + $show->field('permissions', trans('admin.permissions'))->as(function($permission) { |
|
| 74 | 74 | return $permission->pluck('name'); |
| 75 | 75 | })->label(); |
| 76 | 76 | $show->field('created_at', trans('admin.created_at')); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $form->display('created_at', trans('admin.created_at')); |
| 101 | 101 | $form->display('updated_at', trans('admin.updated_at')); |
| 102 | 102 | |
| 103 | - $form->saved(function (Form $form) { |
|
| 103 | + $form->saved(function(Form $form) { |
|
| 104 | 104 | Admin::clearCache(); |
| 105 | 105 | }); |
| 106 | 106 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $form = $this->settingForm(); |
| 104 | 104 | $form->tools( |
| 105 | - function (Form\Tools $tools) { |
|
| 105 | + function(Form\Tools $tools) { |
|
| 106 | 106 | $tools->disableList(); |
| 107 | 107 | $tools->disableDelete(); |
| 108 | 108 | $tools->disableView(); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $form->image('avatar', trans('admin.avatar')); |
| 141 | 141 | $form->password('password', trans('admin.password'))->rules('confirmed|required'); |
| 142 | 142 | $form->password('password_confirmation', trans('admin.password_confirmation'))->rules('required') |
| 143 | - ->default(function ($form) { |
|
| 143 | + ->default(function($form) { |
|
| 144 | 144 | return $form->model()->password; |
| 145 | 145 | }); |
| 146 | 146 | |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $form->ignore(['password_confirmation']); |
| 150 | 150 | |
| 151 | - $form->saving(function (Form $form) { |
|
| 151 | + $form->saving(function(Form $form) { |
|
| 152 | 152 | if ($form->password && $form->model()->password != $form->password) { |
| 153 | 153 | $form->password = Hash::make($form->password); |
| 154 | 154 | } |
| 155 | 155 | }); |
| 156 | 156 | |
| 157 | - $form->saved(function () { |
|
| 157 | + $form->saved(function() { |
|
| 158 | 158 | admin_toastr(trans('admin.update_succeeded')); |
| 159 | 159 | |
| 160 | 160 | return redirect(admin_url('auth/setting')); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | return Admin::guard(); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function show2FaForm(Request $request): View|RedirectResponse |
|
| 226 | + public function show2FaForm(Request $request): View | RedirectResponse |
|
| 227 | 227 | { |
| 228 | 228 | $user = Admin::user(); |
| 229 | 229 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | return view('admin::google2fa.index'); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - public function set2Fa(Request $request): View|RedirectResponse |
|
| 265 | + public function set2Fa(Request $request): View | RedirectResponse |
|
| 266 | 266 | { |
| 267 | 267 | $user = Admin::user(); |
| 268 | 268 | |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | $grid->column('slug', trans('admin.slug')); |
| 34 | 34 | $grid->column('name', trans('admin.name')); |
| 35 | 35 | |
| 36 | - $grid->column('http_path', trans('admin.route'))->display(function ($path) { |
|
| 37 | - return collect(explode("\n", $path))->map(function ($path) { |
|
| 36 | + $grid->column('http_path', trans('admin.route'))->display(function($path) { |
|
| 37 | + return collect(explode("\n", $path))->map(function($path) { |
|
| 38 | 38 | $method = $this->http_method ?: ['ANY']; |
| 39 | 39 | |
| 40 | 40 | if (Str::contains($path, ':')) { |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | $method = explode(',', $method); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $method = collect($method)->map(function ($name) { |
|
| 45 | + $method = collect($method)->map(function($name) { |
|
| 46 | 46 | return strtoupper($name); |
| 47 | - })->map(function ($name) { |
|
| 47 | + })->map(function($name) { |
|
| 48 | 48 | return "<span class='label label-primary'>{$name}</span>"; |
| 49 | 49 | })->implode(' '); |
| 50 | 50 | |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | $grid->column('created_at', trans('admin.created_at')); |
| 60 | 60 | $grid->column('updated_at', trans('admin.updated_at')); |
| 61 | 61 | |
| 62 | - $grid->tools(function (Grid\Tools $tools) { |
|
| 63 | - $tools->batch(function (Grid\Tools\BatchActions $actions) { |
|
| 62 | + $grid->tools(function(Grid\Tools $tools) { |
|
| 63 | + $tools->batch(function(Grid\Tools\BatchActions $actions) { |
|
| 64 | 64 | $actions->disableDelete(); |
| 65 | 65 | }); |
| 66 | 66 | }); |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | $show->field('slug', trans('admin.slug')); |
| 86 | 86 | $show->field('name', trans('admin.name')); |
| 87 | 87 | |
| 88 | - $show->field('http_path', trans('admin.route'))->unescape()->as(function ($path) { |
|
| 89 | - return collect(explode("\r\n", $path))->map(function ($path) { |
|
| 88 | + $show->field('http_path', trans('admin.route'))->unescape()->as(function($path) { |
|
| 89 | + return collect(explode("\r\n", $path))->map(function($path) { |
|
| 90 | 90 | $method = $this->http_method ?: ['ANY']; |
| 91 | 91 | |
| 92 | 92 | if (Str::contains($path, ':')) { |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | $method = explode(',', $method); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $method = collect($method)->map(function ($name) { |
|
| 97 | + $method = collect($method)->map(function($name) { |
|
| 98 | 98 | return strtoupper($name); |
| 99 | - })->map(function ($name) { |
|
| 99 | + })->map(function($name) { |
|
| 100 | 100 | return "<span class='label label-primary'>{$name}</span>"; |
| 101 | 101 | })->implode(' '); |
| 102 | 102 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $form->display('created_at', trans('admin.created_at')); |
| 139 | 139 | $form->display('updated_at', trans('admin.updated_at')); |
| 140 | 140 | |
| 141 | - $form->saved(function (Form $form) { |
|
| 141 | + $form->saved(function(Form $form) { |
|
| 142 | 142 | Admin::clearCache(); |
| 143 | 143 | }); |
| 144 | 144 | |
@@ -42,23 +42,23 @@ discard block |
||
| 42 | 42 | $grid->column('created_at', trans('admin.created_at')); |
| 43 | 43 | $grid->column('updated_at', trans('admin.updated_at')); |
| 44 | 44 | |
| 45 | - $grid->actions(function (Grid\Displayers\Actions $actions) { |
|
| 45 | + $grid->actions(function(Grid\Displayers\Actions $actions) { |
|
| 46 | 46 | if ($actions->getKey() == 1) { |
| 47 | 47 | $actions->disableDelete(); |
| 48 | 48 | } |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | - $grid->tools(function (Grid\Tools $tools) { |
|
| 52 | - $tools->batch(function (Grid\Tools\BatchActions $actions) { |
|
| 51 | + $grid->tools(function(Grid\Tools $tools) { |
|
| 52 | + $tools->batch(function(Grid\Tools\BatchActions $actions) { |
|
| 53 | 53 | $actions->disableDelete(); |
| 54 | 54 | }); |
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | 57 | $grid->filter(function($filter) { |
| 58 | - $filter->column(1/2, function ($filter) { |
|
| 58 | + $filter->column(1 / 2, function($filter) { |
|
| 59 | 59 | $filter->like('username', trans('admin.username')); |
| 60 | 60 | $filter->like('name', trans('admin.name')); |
| 61 | - $filter->where(function ($query) { |
|
| 61 | + $filter->where(function($query) { |
|
| 62 | 62 | $user_ids = DB::table(config('admin.database.role_users_table')) |
| 63 | 63 | ->where('role_id', $this->input) |
| 64 | 64 | ->pluck('user_id')->toArray(); |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | Role::pluck('name', 'id')->toArray() |
| 68 | 68 | ); |
| 69 | 69 | }); |
| 70 | - $filter->column(1/2, function ($filter) { |
|
| 70 | + $filter->column(1 / 2, function($filter) { |
|
| 71 | 71 | $filter->bool('is_blocked', true, trans('admin.ext.is_blocked')); |
| 72 | 72 | $filter->bool('is_google2fa', true, trans('admin.ext.is_google2fa')); |
| 73 | 73 | }); |
| 74 | 74 | }); |
| 75 | 75 | |
| 76 | - $grid->export(function ($export) { |
|
| 76 | + $grid->export(function($export) { |
|
| 77 | 77 | $export->originalValue(['is_blocked', 'is_need_relogin', 'is_google2fa']); |
| 78 | - $export->column('roles', function ($value) { |
|
| 78 | + $export->column('roles', function($value) { |
|
| 79 | 79 | return $value ? str_replace(' ', ', ', strip_tags($value)) : ''; |
| 80 | 80 | }); |
| 81 | 81 | }); |
@@ -99,10 +99,10 @@ discard block |
||
| 99 | 99 | $show->field('id', 'ID'); |
| 100 | 100 | $show->field('username', trans('admin.username')); |
| 101 | 101 | $show->field('name', trans('admin.name')); |
| 102 | - $show->field('roles', trans('admin.roles'))->as(function ($roles) { |
|
| 102 | + $show->field('roles', trans('admin.roles'))->as(function($roles) { |
|
| 103 | 103 | return $roles->pluck('name'); |
| 104 | 104 | })->label(); |
| 105 | - $show->field('permissions', trans('admin.permissions'))->as(function ($permission) { |
|
| 105 | + $show->field('permissions', trans('admin.permissions'))->as(function($permission) { |
|
| 106 | 106 | return $permission->pluck('name'); |
| 107 | 107 | })->label(); |
| 108 | 108 | $show->field('is_blocked', trans('admin.ext.is_blocked'))->check(); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $form->image('avatar', trans('admin.avatar')); |
| 142 | 142 | $form->password('password', trans('admin.password'))->rules('required|confirmed'); |
| 143 | 143 | $form->password('password_confirmation', trans('admin.password_confirmation'))->rules('required') |
| 144 | - ->default(function ($form) { |
|
| 144 | + ->default(function($form) { |
|
| 145 | 145 | return $form->model()->password; |
| 146 | 146 | }); |
| 147 | 147 | |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | $form->display('created_at', trans('admin.created_at')); |
| 164 | 164 | $form->display('updated_at', trans('admin.updated_at')); |
| 165 | 165 | |
| 166 | - $form->saving(function (Form $form) { |
|
| 166 | + $form->saving(function(Form $form) { |
|
| 167 | 167 | if ($form->password && $form->model()->password != $form->password) { |
| 168 | 168 | $form->password = Hash::make($form->password); |
| 169 | 169 | } |
| 170 | 170 | }); |
| 171 | 171 | |
| 172 | - $form->saved(function (Form $form) { |
|
| 172 | + $form->saved(function(Form $form) { |
|
| 173 | 173 | Admin::clearCache(); |
| 174 | 174 | }); |
| 175 | 175 | |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $grid->column('id', 'ID')->sortable(); |
| 29 | 29 | $grid->column('user.name', 'User'); |
| 30 | - $grid->column('method')->display(function ($method) { |
|
| 30 | + $grid->column('method')->display(function($method) { |
|
| 31 | 31 | $color = Arr::get(OperationLog::$methodColors, $method, 'grey'); |
| 32 | 32 | |
| 33 | 33 | return "<span class=\"badge bg-$color\">$method</span>"; |
| 34 | 34 | }); |
| 35 | 35 | $grid->column('path'); |
| 36 | 36 | $grid->column('ip'); |
| 37 | - $grid->column('input')->display(function ($input) { |
|
| 37 | + $grid->column('input')->display(function($input) { |
|
| 38 | 38 | $input = json_decode($input, true); |
| 39 | 39 | $input = Arr::except($input, ['_pjax', '_token', '_method', '_previous_']); |
| 40 | 40 | if (empty($input)) { |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $grid->column('created_at', trans('admin.created_at')); |
| 51 | 51 | |
| 52 | - $grid->actions(function (Grid\Displayers\Actions $actions) { |
|
| 52 | + $grid->actions(function(Grid\Displayers\Actions $actions) { |
|
| 53 | 53 | $actions->disableEdit(); |
| 54 | 54 | $actions->disableView(); |
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | 57 | $grid->disableCreateButton(); |
| 58 | 58 | |
| 59 | - $grid->filter(function (Grid\Filter $filter) { |
|
| 59 | + $grid->filter(function(Grid\Filter $filter) { |
|
| 60 | 60 | $userModel = config('admin.database.users_model'); |
| 61 | 61 | |
| 62 | 62 | $filter->equal('user_id', 'User')->select($userModel::all()->pluck('name', 'id')); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function removeFilterByID($id) |
| 289 | 289 | { |
| 290 | - $this->filters = array_filter($this->filters, function (AbstractFilter $filter) use ($id) { |
|
| 290 | + $this->filters = array_filter($this->filters, function(AbstractFilter $filter) use ($id) { |
|
| 291 | 291 | return $filter->getId() != $id; |
| 292 | 292 | }); |
| 293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | { |
| 302 | 302 | $inputs = Arr::dot(request()->all()); |
| 303 | 303 | |
| 304 | - $inputs = array_filter($inputs, function ($input) { |
|
| 304 | + $inputs = array_filter($inputs, function($input) { |
|
| 305 | 305 | return $input !== '' && !is_null($input); |
| 306 | 306 | }); |
| 307 | 307 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - return tap(array_filter($conditions), function ($conditions) { |
|
| 332 | + return tap(array_filter($conditions), function($conditions) { |
|
| 333 | 333 | if (!empty($conditions)) { |
| 334 | 334 | $this->expand(); |
| 335 | 335 | } |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | return $inputs; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - $inputs = collect($inputs)->filter(function ($input, $key) { |
|
| 350 | + $inputs = collect($inputs)->filter(function($input, $key) { |
|
| 351 | 351 | return Str::startsWith($key, "{$this->name}_"); |
| 352 | - })->mapWithKeys(function ($val, $key) { |
|
| 352 | + })->mapWithKeys(function($val, $key) { |
|
| 353 | 353 | $key = str_replace("{$this->name}_", '', $key); |
| 354 | 354 | |
| 355 | 355 | return [$key => $val]; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | public function scope($key, $label = '') |
| 421 | 421 | { |
| 422 | - return tap(new Scope($key, $label), function (Scope $scope) { |
|
| 422 | + return tap(new Scope($key, $label), function(Scope $scope) { |
|
| 423 | 423 | return $this->scopes->push($scope); |
| 424 | 424 | }); |
| 425 | 425 | } |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | { |
| 454 | 454 | $key = request(Scope::QUERY_NAME); |
| 455 | 455 | |
| 456 | - return $this->scopes->first(function ($scope) use ($key) { |
|
| 456 | + return $this->scopes->first(function($scope) use ($key) { |
|
| 457 | 457 | return $scope->key == $key; |
| 458 | 458 | }); |
| 459 | 459 | } |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | $columns->push($pageKey); |
| 580 | 580 | |
| 581 | - $groupNames = collect($this->filters)->filter(function ($filter) { |
|
| 581 | + $groupNames = collect($this->filters)->filter(function($filter) { |
|
| 582 | 582 | return $filter instanceof Filter\Group; |
| 583 | - })->map(function (AbstractFilter $filter) { |
|
| 583 | + })->map(function(AbstractFilter $filter) { |
|
| 584 | 584 | return "{$filter->getId()}_group"; |
| 585 | 585 | }); |
| 586 | 586 | |
@@ -672,8 +672,8 @@ discard block |
||
| 672 | 672 | public function bool(string $field_name, bool $is_int = false, ?string $label = null): void |
| 673 | 673 | { |
| 674 | 674 | if ($is_int) { |
| 675 | - $this->where(function ($query) use ($field_name) { |
|
| 676 | - $query->whereRaw('`'.$field_name.'` = '.((int)$this->input)); |
|
| 675 | + $this->where(function($query) use ($field_name) { |
|
| 676 | + $query->whereRaw('`'.$field_name.'` = '.((int) $this->input)); |
|
| 677 | 677 | }, $label ?? $field_name, $field_name)->radio([ |
| 678 | 678 | '' => 'All', |
| 679 | 679 | 1 => 'Yes', |