@@ -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', |
@@ -122,12 +122,14 @@ discard block |
||
| 122 | 122 | if (!empty($periods)) { |
| 123 | 123 | $res = []; |
| 124 | 124 | foreach ($periods as $period) { |
| 125 | - if (array_key_exists($period, self::PERIODS)) |
|
| 126 | - $res[] = $period; |
|
| 125 | + if (array_key_exists($period, self::PERIODS)) { |
|
| 126 | + $res[] = $period; |
|
| 127 | + } |
|
| 127 | 128 | } |
| 128 | 129 | |
| 129 | - if (!empty($res)) |
|
| 130 | - $this->periods = $res; |
|
| 130 | + if (!empty($res)) { |
|
| 131 | + $this->periods = $res; |
|
| 132 | + } |
|
| 131 | 133 | } |
| 132 | 134 | |
| 133 | 135 | return $this; |
@@ -140,8 +142,9 @@ discard block |
||
| 140 | 142 | public function condition($inputs) |
| 141 | 143 | { |
| 142 | 144 | $type = $inputs[$this->column]['type'] ?? $this->getDefault(); |
| 143 | - if ($this->ignore || !$type || !array_key_exists($type, self::PERIODS)) |
|
| 144 | - return; |
|
| 145 | + if ($this->ignore || !$type || !array_key_exists($type, self::PERIODS)) { |
|
| 146 | + return; |
|
| 147 | + } |
|
| 145 | 148 | |
| 146 | 149 | if ($type === self::CUSTOM_DATE || $type === self::CUSTOM_DATETIME) { |
| 147 | 150 | return $this->handleCustomDate($inputs, $type); |
@@ -180,20 +183,23 @@ discard block |
||
| 180 | 183 | protected function handleCustomDate(array $inputs, string $type): mixed |
| 181 | 184 | { |
| 182 | 185 | $value = $inputs[$this->column][$type] ?? null; |
| 183 | - if (!$value) |
|
| 184 | - return null; |
|
| 186 | + if (!$value) { |
|
| 187 | + return null; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | $format = self::CUSTOM_FORMATS[$type]; |
| 187 | 191 | foreach ($value as $key => $row) { |
| 188 | 192 | $date = \DateTime::createFromFormat($format, $row); |
| 189 | - if (!$date) |
|
| 190 | - return null; |
|
| 193 | + if (!$date) { |
|
| 194 | + return null; |
|
| 195 | + } |
|
| 191 | 196 | |
| 192 | 197 | $value[$key] = $date->format($format); |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | - if ($type === self::CUSTOM_DATE && !empty($value['end'])) |
|
| 196 | - $value['end'] .= ' 23:59:59'; |
|
| 200 | + if ($type === self::CUSTOM_DATE && !empty($value['end'])) { |
|
| 201 | + $value['end'] .= ' 23:59:59'; |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | 204 | return match (true) { |
| 199 | 205 | !isset($value['start']) => $this->buildCondition($this->column, '<=', $value['end']), |
@@ -286,8 +292,9 @@ discard block |
||
| 286 | 292 | public static function isNotFilled(string $column): bool |
| 287 | 293 | { |
| 288 | 294 | $request = request()->query($column); |
| 289 | - if (!$request) |
|
| 290 | - return true; |
|
| 295 | + if (!$request) { |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 291 | 298 | |
| 292 | 299 | $type = $request['type'] ?? null; |
| 293 | 300 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public function json(int $max_width = 600) |
| 438 | 438 | { |
| 439 | - return $this->display(function ($val) { |
|
| 439 | + return $this->display(function($val) { |
|
| 440 | 440 | $json = json_decode($val, true); |
| 441 | 441 | if (!$json || !is_array($json)) |
| 442 | 442 | return e($val); |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | */ |
| 470 | 470 | public function money(int $decimals = 2) |
| 471 | 471 | { |
| 472 | - return $this->display(function ($val) use ($decimals) { |
|
| 473 | - return is_null($val) ? '' : number_format((float)$val, $decimals); |
|
| 472 | + return $this->display(function($val) use ($decimals) { |
|
| 473 | + return is_null($val) ? '' : number_format((float) $val, $decimals); |
|
| 474 | 474 | }); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | $column = $this; |
| 490 | 490 | |
| 491 | - return $this->display(function ($value) use ($grid, $column, $abstract, $arguments) { |
|
| 491 | + return $this->display(function($value) use ($grid, $column, $abstract, $arguments) { |
|
| 492 | 492 | /** @var AbstractDisplayer $displayer */ |
| 493 | 493 | $displayer = new $abstract($value, $grid, $column, $this); |
| 494 | 494 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | $grid = $this->grid; |
| 539 | 539 | |
| 540 | - return $this->display(function ($_, $column) use ($action, $grid) { |
|
| 540 | + return $this->display(function($_, $column) use ($action, $grid) { |
|
| 541 | 541 | /** @var RowAction $action */ |
| 542 | 542 | $action = new $action(); |
| 543 | 543 | |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $grid = $this->grid; |
| 666 | 666 | $column = $this; |
| 667 | 667 | |
| 668 | - $this->display(function ($value) use ($grid, $column, $class) { |
|
| 668 | + $this->display(function($value) use ($grid, $column, $class) { |
|
| 669 | 669 | /** @var AbstractDisplayer $definition */ |
| 670 | 670 | $definition = new $class($value, $grid, $column, $this); |
| 671 | 671 | |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | protected function htmlEntityEncode($item) |
| 684 | 684 | { |
| 685 | 685 | if (is_array($item)) { |
| 686 | - array_walk_recursive($item, function (&$value) { |
|
| 686 | + array_walk_recursive($item, function(&$value) { |
|
| 687 | 687 | $value = htmlentities($value ?? ''); |
| 688 | 688 | }); |
| 689 | 689 | } else { |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | */ |
| 721 | 721 | protected function callSupportDisplayer($abstract, $arguments) |
| 722 | 722 | { |
| 723 | - return $this->display(function ($value) use ($abstract, $arguments) { |
|
| 723 | + return $this->display(function($value) use ($abstract, $arguments) { |
|
| 724 | 724 | if (is_array($value) || $value instanceof Arrayable) { |
| 725 | 725 | return call_user_func_array([collect($value), $abstract], $arguments); |
| 726 | 726 | } |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | protected function callBuiltinDisplayer($abstract, $arguments) |
| 745 | 745 | { |
| 746 | 746 | if ($abstract instanceof Closure) { |
| 747 | - return $this->display(function ($value) use ($abstract, $arguments) { |
|
| 747 | + return $this->display(function($value) use ($abstract, $arguments) { |
|
| 748 | 748 | return $abstract->call($this, ...array_merge([$value], $arguments)); |
| 749 | 749 | }); |
| 750 | 750 | } |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | $grid = $this->grid; |
| 754 | 754 | $column = $this; |
| 755 | 755 | |
| 756 | - return $this->display(function ($value) use ($abstract, $grid, $column, $arguments) { |
|
| 756 | + return $this->display(function($value) use ($abstract, $grid, $column, $arguments) { |
|
| 757 | 757 | /** @var AbstractDisplayer $displayer */ |
| 758 | 758 | $displayer = new $abstract($value, $grid, $column, $this); |
| 759 | 759 | |
@@ -438,8 +438,9 @@ |
||
| 438 | 438 | { |
| 439 | 439 | return $this->display(function ($val) { |
| 440 | 440 | $json = json_decode($val, true); |
| 441 | - if (!$json || !is_array($json)) |
|
| 442 | - return e($val); |
|
| 441 | + if (!$json || !is_array($json)) { |
|
| 442 | + return e($val); |
|
| 443 | + } |
|
| 443 | 444 | return '<pre>'.e(json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)).'</pre>'; |
| 444 | 445 | })->style(implode(';', [ |
| 445 | 446 | 'max-width: '.$max_width.'px', |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $this->compatibleBlade(); |
| 92 | 92 | |
| 93 | - Blade::directive('box', function ($title) { |
|
| 93 | + Blade::directive('box', function($title) { |
|
| 94 | 94 | return "<?php \$box = new \Encore\Admin\Widgets\Box({$title}, '"; |
| 95 | 95 | }); |
| 96 | 96 | |
| 97 | - Blade::directive('endbox', function ($expression) { |
|
| 97 | + Blade::directive('endbox', function($expression) { |
|
| 98 | 98 | return "'); echo \$box->render(); ?>"; |
| 99 | 99 | }); |
| 100 | 100 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function macroRouter() |
| 155 | 155 | { |
| 156 | - Router::macro('content', function ($uri, $content, $options = []) { |
|
| 157 | - return $this->match(['GET', 'HEAD'], $uri, function (Content $layout) use ($content, $options) { |
|
| 156 | + Router::macro('content', function($uri, $content, $options = []) { |
|
| 157 | + return $this->match(['GET', 'HEAD'], $uri, function(Content $layout) use ($content, $options) { |
|
| 158 | 158 | return $layout |
| 159 | 159 | ->title(Arr::get($options, 'title', ' ')) |
| 160 | 160 | ->description(Arr::get($options, 'desc', ' ')) |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | }); |
| 163 | 163 | }); |
| 164 | 164 | |
| 165 | - Router::macro('component', function ($uri, $component, $data = [], $options = []) { |
|
| 166 | - return $this->match(['GET', 'HEAD'], $uri, function (Content $layout) use ($component, $data, $options) { |
|
| 165 | + Router::macro('component', function($uri, $component, $data = [], $options = []) { |
|
| 166 | + return $this->match(['GET', 'HEAD'], $uri, function(Content $layout) use ($component, $data, $options) { |
|
| 167 | 167 | return $layout |
| 168 | 168 | ->title(Arr::get($options, 'title', ' ')) |
| 169 | 169 | ->description(Arr::get($options, 'desc', ' ')) |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function bool() |
| 191 | 191 | { |
| 192 | - return $this->as(function ($val) { |
|
| 192 | + return $this->as(function($val) { |
|
| 193 | 193 | return is_null($val) ? 'Undefined' : ($val ? 'Yes' : 'No'); |
| 194 | 194 | }); |
| 195 | 195 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function check() |
| 203 | 203 | { |
| 204 | - return $this->unescape()->as(function ($val) { |
|
| 204 | + return $this->unescape()->as(function($val) { |
|
| 205 | 205 | return is_null($val) ? '<i class="fa fa-check text-gray"></i>' : ($val ? '<i class="fa fa-check text-green"></i>' : '<i class="fa fa-close text-red"></i>'); |
| 206 | 206 | }); |
| 207 | 207 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | public static function _jsonParse() |
| 245 | 245 | { |
| 246 | - return function ($val) { |
|
| 246 | + return function($val) { |
|
| 247 | 247 | $json = json_decode($val, true); |
| 248 | 248 | if (!$json || !is_array($json)) |
| 249 | 249 | return e($val); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function using(array $values, $default = null) |
| 274 | 274 | { |
| 275 | - return $this->as(function ($value) use ($values, $default) { |
|
| 275 | + return $this->as(function($value) use ($values, $default) { |
|
| 276 | 276 | if (is_null($value)) { |
| 277 | 277 | return $default; |
| 278 | 278 | } |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function image($server = '', $width = 200, $height = 200) |
| 294 | 294 | { |
| 295 | - return $this->unescape()->as(function ($images) use ($server, $width, $height) { |
|
| 296 | - return collect($images)->map(function ($path) use ($server, $width, $height) { |
|
| 295 | + return $this->unescape()->as(function($images) use ($server, $width, $height) { |
|
| 296 | + return collect($images)->map(function($path) use ($server, $width, $height) { |
|
| 297 | 297 | if (empty($path)) { |
| 298 | 298 | return ''; |
| 299 | 299 | } |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public function carousel($width = 300, $height = 200, $server = '') |
| 330 | 330 | { |
| 331 | - return $this->unescape()->as(function ($images) use ($server, $width, $height) { |
|
| 332 | - $items = collect($images)->map(function ($path) use ($server, $width, $height) { |
|
| 331 | + return $this->unescape()->as(function($images) use ($server, $width, $height) { |
|
| 332 | + $items = collect($images)->map(function($path) use ($server, $width, $height) { |
|
| 333 | 333 | if (empty($path)) { |
| 334 | 334 | return ''; |
| 335 | 335 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | { |
| 370 | 370 | $field = $this; |
| 371 | 371 | |
| 372 | - return $this->unescape()->as(function ($path) use ($server, $download, $field) { |
|
| 372 | + return $this->unescape()->as(function($path) use ($server, $download, $field) { |
|
| 373 | 373 | $name = basename($path); |
| 374 | 374 | |
| 375 | 375 | $field->border = false; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | */ |
| 424 | 424 | public function link($href = '', $target = '_blank') |
| 425 | 425 | { |
| 426 | - return $this->unescape()->as(function ($link) use ($href, $target) { |
|
| 426 | + return $this->unescape()->as(function($link) use ($href, $target) { |
|
| 427 | 427 | $href = $href ?: $link; |
| 428 | 428 | |
| 429 | 429 | return "<a href='$href' target='{$target}'>{$link}</a>"; |
@@ -439,12 +439,12 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | public function label($style = 'success') |
| 441 | 441 | { |
| 442 | - return $this->unescape()->as(function ($value) use ($style) { |
|
| 442 | + return $this->unescape()->as(function($value) use ($style) { |
|
| 443 | 443 | if ($value instanceof Arrayable) { |
| 444 | 444 | $value = $value->toArray(); |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - return collect((array) $value)->map(function ($name) use ($style) { |
|
| 447 | + return collect((array) $value)->map(function($name) use ($style) { |
|
| 448 | 448 | return "<span class='label label-{$style}'>$name</span>"; |
| 449 | 449 | })->implode(' '); |
| 450 | 450 | }); |
@@ -459,12 +459,12 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public function badge($style = 'blue') |
| 461 | 461 | { |
| 462 | - return $this->unescape()->as(function ($value) use ($style) { |
|
| 462 | + return $this->unescape()->as(function($value) use ($style) { |
|
| 463 | 463 | if ($value instanceof Arrayable) { |
| 464 | 464 | $value = $value->toArray(); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - return collect((array) $value)->map(function ($name) use ($style) { |
|
| 467 | + return collect((array) $value)->map(function($name) use ($style) { |
|
| 468 | 468 | return "<span class='badge bg-{$style}'>$name</span>"; |
| 469 | 469 | })->implode(' '); |
| 470 | 470 | }); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | public function number($decimals = 0, $decimal_seperator = '.', $thousands_seperator = ',') |
| 483 | 483 | { |
| 484 | - return $this->unescape()->as(function ($value) use ($decimals, $decimal_seperator, $thousands_seperator) { |
|
| 484 | + return $this->unescape()->as(function($value) use ($decimals, $decimal_seperator, $thousands_seperator) { |
|
| 485 | 485 | return number_format($value, $decimals, $decimal_seperator, $thousands_seperator); |
| 486 | 486 | }); |
| 487 | 487 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | { |
| 496 | 496 | $field = $this; |
| 497 | 497 | |
| 498 | - return $this->unescape()->as(function ($value) use ($field) { |
|
| 498 | + return $this->unescape()->as(function($value) use ($field) { |
|
| 499 | 499 | if (is_string($value)) { |
| 500 | 500 | $content = json_decode($value, true); |
| 501 | 501 | } else { |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | */ |
| 520 | 520 | public function filesize() |
| 521 | 521 | { |
| 522 | - return $this->as(function ($value) { |
|
| 522 | + return $this->as(function($value) { |
|
| 523 | 523 | return file_size($value); |
| 524 | 524 | }); |
| 525 | 525 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $field = $this; |
| 679 | 679 | |
| 680 | - return $this->as(function ($value) use ($extend, $field, $arguments) { |
|
| 680 | + return $this->as(function($value) use ($extend, $field, $arguments) { |
|
| 681 | 681 | if (!$extend->border) { |
| 682 | 682 | $field->border = false; |
| 683 | 683 | } |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | public function render() |
| 737 | 737 | { |
| 738 | 738 | if ($this->showAs->isNotEmpty()) { |
| 739 | - $this->showAs->each(function ($callable) { |
|
| 739 | + $this->showAs->each(function($callable) { |
|
| 740 | 740 | $this->value = $callable->call( |
| 741 | 741 | $this->parent->getModel(), |
| 742 | 742 | $this->value |
@@ -245,8 +245,9 @@ |
||
| 245 | 245 | { |
| 246 | 246 | return function ($val) { |
| 247 | 247 | $json = json_decode($val, true); |
| 248 | - if (!$json || !is_array($json)) |
|
| 249 | - return e($val); |
|
| 248 | + if (!$json || !is_array($json)) { |
|
| 249 | + return e($val); |
|
| 250 | + } |
|
| 250 | 251 | $res = '<pre>'; |
| 251 | 252 | foreach ($json as $lang => $text) { |
| 252 | 253 | if (is_string($text) || is_numeric($text)) { |