From e7bbada3c43f75e52f2f7e1d52786641e80d1aa6 Mon Sep 17 00:00:00 2001 From: Dudix Date: Tue, 18 Apr 2017 11:12:25 +0200 Subject: [PATCH 0001/1424] add polish language --- lang/pl/lang.php | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lang/pl/lang.php diff --git a/lang/pl/lang.php b/lang/pl/lang.php new file mode 100644 index 0000000000..b8f9ff247f --- /dev/null +++ b/lang/pl/lang.php @@ -0,0 +1,87 @@ + 'Dostępny', + 'login' => 'Zaloguj', + 'logout' => 'Wyloguj', + 'setting' => 'Ustawienia', + 'name' => 'Nazwa', + 'username' => 'Nazwa użytkownika', + 'password' => 'Hasło', + 'password_confirmation' => 'Potwierdzenie hasła', + 'remember_me' => 'Zapamiętaj mnie', + 'user_setting' => 'Ustawienia konta', + 'avatar' => 'Avatar', + 'member_since' => 'Dołączył', + + 'list' => 'Lista', + 'new' => 'Dodaj', + 'create' => 'Dodaj', + 'delete' => 'Skasuj', + 'remove' => 'Usuń', + 'edit' => 'Edytuj', + 'view' => 'Zobacz', + 'browse' => 'Przeglądaj', + 'reset' => 'Resetuj', + 'export' => 'Eksportuj', + 'batch_delete' => 'Batch delete', + 'save' => 'Zapisz', + 'refresh' => 'Odswież', + 'order' => 'Sortuj', + 'expand' => 'Rozwiń', + 'collapse' => 'Zwiń', + 'filter' => 'Filtruj', + 'close' => 'Zamknij', + 'show' => 'Wyświetl', + 'entries' => 'pozycji', + 'captcha' => 'Captcha', + + 'action' => 'Akcja', + 'title' => 'Tytuł', + 'description' => 'Opis', + 'back' => 'Powrót', + 'back_to_list' => 'Powrót do listy', + 'submit' => 'Wyślij', + 'menu' => 'Menu', + 'input' => 'Wprowadź', + 'succeeded' => 'Sukces', + 'failed' => 'Błąd', + 'delete_confirm' => 'Czy na pewno chcesz usunąć ten element?', + 'delete_succeeded' => 'Kasowanie zakończone sukcesem.', + 'delete_failed' => 'Kasowanie zakończone niepowodzeniem.', + 'update_succeeded' => 'Aktualizacja danych zakończona sukcesem.', + 'save_succeeded' => 'Zapisz zakończony sukcesem.', + 'refresh_succeeded'=> 'Odświeżenie zakończone sukcesem.', + 'login_successful' => 'Zalogowano prawidłowo.', + + 'choose' => 'Wybierz', + 'choose_file' => 'Wybierz plik', + 'choose_image' => 'Wybierz obrazek', + + 'more' => 'Więcej', + 'deny' => 'Brak odpowiednich uprawnień.', + + 'administrator' => 'Administrator', + 'roles' => 'Rola', + 'permissions' => 'Uprawnienia', + 'slug' => 'Slug (URL)', + + 'created_at' => 'Utworzenie', + 'updated_at' => 'Aktualizacja', + + 'alert' => 'Informacja', + + 'parent_id' => 'Rodzic', + 'icon' => 'Ikona', + 'uri' => 'URI', + + 'operation_log' => 'Log operacji', + 'parent_select_error' => 'Nieprawidłowy wybór rodzica', + + 'pagination' => [ + 'range' => 'Wyświetlanie pozycji od :first do :last z :total', + ] + +]; + +?> From ec96cecd8e7386c11d50c0161126533766ce5376 Mon Sep 17 00:00:00 2001 From: grassnrz Date: Sat, 14 Oct 2017 14:00:24 +0800 Subject: [PATCH 0002/1424] Update NestedForm.php bug fix in php7 --- src/Form/NestedForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/NestedForm.php b/src/Form/NestedForm.php index 4a3a565713..c14e94519b 100644 --- a/src/Form/NestedForm.php +++ b/src/Form/NestedForm.php @@ -337,7 +337,7 @@ protected function formatField(Field $field) { $column = $field->column(); - $elementName = $elementClass = $errorKey = ''; + $elementName = $elementClass = $errorKey = []; $key = $this->key ?: 'new_'.static::DEFAULT_KEY_NAME; From 680c7f0d66d0a67aaa8301a30e2c2e548112edf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B9=BF=E8=BE=89?= Date: Thu, 26 Oct 2017 18:18:03 +0800 Subject: [PATCH 0003/1424] Fix the problem of creating a database error while executing the Travis CI script for the second time. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5dcb00714f..31b4c574df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ services: - mysql before_script: - - mysql -e 'create database laravel_admin;' + - mysql -e 'create database if not exists laravel_admin;' - travis_retry composer self-update - travis_retry composer install --no-interaction From d7067d692871f84f77ffd9099d551ecf51a3071a Mon Sep 17 00:00:00 2001 From: z-song Date: Mon, 30 Oct 2017 16:31:12 +0800 Subject: [PATCH 0004/1424] select field support group options and set configuration --- resources/views/form/select.blade.php | 18 +++- src/Form/Field/Select.php | 117 ++++++++++++++++++++------ 2 files changed, 107 insertions(+), 28 deletions(-) diff --git a/resources/views/form/select.blade.php b/resources/views/form/select.blade.php index 01cba22f68..8218a674e4 100644 --- a/resources/views/form/select.blade.php +++ b/resources/views/form/select.blade.php @@ -9,10 +9,20 @@ @include('admin::form.help-block') diff --git a/src/Form/Field/Select.php b/src/Form/Field/Select.php index c21aac9c60..78e329c0a3 100644 --- a/src/Form/Field/Select.php +++ b/src/Form/Field/Select.php @@ -9,37 +9,29 @@ class Select extends Field { + /** + * @var array + */ protected static $css = [ '/vendor/laravel-admin/AdminLTE/plugins/select2/select2.min.css', ]; + /** + * @var array + */ protected static $js = [ '/vendor/laravel-admin/AdminLTE/plugins/select2/select2.full.min.js', ]; - public function render() - { - if (empty($this->script)) { - $this->script = <<getElementClassSelector()}").select2({ - allowClear: true, - placeholder: "{$this->label}" -}); -EOF; - } - - if ($this->options instanceof \Closure) { - if ($this->form) { - $this->options = $this->options->bindTo($this->form->model()); - } - - $this->options(call_user_func($this->options, $this->value)); - } - - $this->options = array_filter($this->options); + /** + * @var array + */ + protected $groups = []; - return parent::render()->with(['options' => $this->options]); - } + /** + * @var array + */ + protected $config = []; /** * Set options. @@ -52,7 +44,7 @@ public function options($options = []) { // remote options if (is_string($options)) { - return call_user_func_array([$this, 'loadOptionsFromRemote'], func_get_args()); + return $this->loadRemoteOptions(...func_get_args()); } if ($options instanceof Arrayable) { @@ -68,6 +60,35 @@ public function options($options = []) return $this; } + /** + * @param array $groups + */ + + /** + * Set option groups. + * + * eg: $group = [ + * [ + * 'label' => 'xxxx', + * 'options' => [ + * 1 => 'foo', + * 2 => 'bar', + * ... + * ], + * ... + * ] + * + * @param array $groups + * + * @return $this + */ + public function groups(array $groups) + { + $this->groups = $groups; + + return $this; + } + /** * Load options for other select on change. * @@ -118,7 +139,7 @@ public function load($field, $sourceUrl, $idField = 'id', $textField = 'text') * * @return $this */ - protected function loadOptionsFromRemote($url, $parameters = [], $options = []) + protected function loadRemoteOptions($url, $parameters = [], $options = []) { $ajaxOptions = [ 'url' => $url.'?'.http_build_query($parameters), @@ -187,4 +208,52 @@ public function ajax($url, $idField = 'id', $textField = 'text') return $this; } + + /** + * Set config for select2 + * + * all configurations see https://select2.org/configuration/options-api + * + * @param string $key + * @param mixed $val + * @return $this + */ + public function config($key, $val) + { + $this->config[$key] = $val; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function render() + { + $configs = array_merge([ + 'allowClear' => true, + 'placeholder' => $this->label, + ], $this->config); + + $configs = json_encode($configs); + + if (empty($this->script)) { + $this->script = "$(\"{$this->getElementClassSelector()}\").select2($configs);"; + } + + if ($this->options instanceof \Closure) { + if ($this->form) { + $this->options = $this->options->bindTo($this->form->model()); + } + + $this->options(call_user_func($this->options, $this->value)); + } + + $this->options = array_filter($this->options); + + return parent::render()->with([ + 'options' => $this->options, + 'groups' => $this->groups, + ]); + } } From 818349ada1846d3bdf41d3b1c144576f85243936 Mon Sep 17 00:00:00 2001 From: Song Date: Fri, 3 Nov 2017 01:50:50 +0000 Subject: [PATCH 0005/1424] Apply fixes from StyleCI --- config/admin.php | 32 ++++----- resources/lang/en/admin.php | 8 +-- resources/lang/zh-CN/admin.php | 8 +-- src/Admin.php | 6 +- src/AdminServiceProvider.php | 10 +-- src/Auth/Database/AdminTablesSeeder.php | 10 +-- src/Auth/Database/OperationLog.php | 8 +-- src/Exception/Handler.php | 8 +-- src/Extension.php | 6 +- src/Form.php | 92 ++++++++++++------------- src/Form/Builder.php | 6 +- src/Form/Field.php | 24 +++---- src/Form/Field/Currency.php | 8 +-- src/Form/Field/HasMany.php | 10 +-- src/Form/Field/MultipleFile.php | 2 +- src/Form/Field/UploadField.php | 4 +- src/Grid.php | 38 +++++----- src/Grid/Displayers/Editable.php | 8 +-- src/Grid/Filter.php | 4 +- src/Grid/Filter/Presenter/Text.php | 6 +- src/Middleware/Pjax.php | 8 +-- src/Tree.php | 16 ++--- src/Widgets/Alert.php | 8 +-- src/Widgets/Box.php | 8 +-- src/Widgets/Callout.php | 6 +- src/Widgets/Carousel.php | 6 +- src/Widgets/Collapse.php | 6 +- src/Widgets/Form.php | 4 +- src/Widgets/InfoBox.php | 8 +-- src/Widgets/Navbar.php | 4 +- src/Widgets/Table.php | 8 +-- tests/UserFormTest.php | 2 +- tests/config/admin.php | 32 ++++----- tests/config/filesystems.php | 6 +- tests/routes.php | 6 +- 35 files changed, 213 insertions(+), 213 deletions(-) diff --git a/config/admin.php b/config/admin.php index 79da185cbf..f178e976a0 100644 --- a/config/admin.php +++ b/config/admin.php @@ -5,12 +5,12 @@ /* * Laravel-admin name. */ - 'name' => 'Laravel-admin', + 'name' => 'Laravel-admin', /* * Logo in admin panel header. */ - 'logo' => 'Laravel admin', + 'logo' => 'Laravel admin', /* * Mini-logo in admin panel header. @@ -24,9 +24,9 @@ 'prefix' => 'admin', - 'namespace' => 'App\\Admin\\Controllers', + 'namespace' => 'App\\Admin\\Controllers', - 'middleware' => ['web', 'admin'], + 'middleware' => ['web', 'admin'], ], /* @@ -37,7 +37,7 @@ /* * Laravel-admin html title. */ - 'title' => 'Admin', + 'title' => 'Admin', /* * Use `https`. @@ -66,13 +66,13 @@ /* * Laravel-admin upload setting. */ - 'upload' => [ + 'upload' => [ 'disk' => 'admin', - 'directory' => [ - 'image' => 'images', - 'file' => 'files', + 'directory' => [ + 'image' => 'images', + 'file' => 'files', ], ], @@ -82,7 +82,7 @@ 'database' => [ // Database connection for following tables. - 'connection' => '', + 'connection' => '', // User tables and model. 'users_table' => 'admin_users', @@ -97,8 +97,8 @@ 'permissions_model' => Encore\Admin\Auth\Database\Permission::class, // Menu table and model. - 'menu_table' => 'admin_menu', - 'menu_model' => Encore\Admin\Auth\Database\Menu::class, + 'menu_table' => 'admin_menu', + 'menu_model' => Encore\Admin\Auth\Database\Menu::class, // Pivot table for table above. 'operation_log_table' => 'admin_operation_log', @@ -111,7 +111,7 @@ /* * By setting this option to open or close operation log in laravel-admin. */ - 'operation_log' => [ + 'operation_log' => [ 'enable' => true, @@ -129,7 +129,7 @@ /* * @see https://adminlte.io/docs/2.4/layout */ - 'skin' => 'skin-blue-light', + 'skin' => 'skin-blue-light', /* |---------------------------------------------------------| @@ -140,12 +140,12 @@ | | sidebar-mini | |---------------------------------------------------------| */ - 'layout' => ['sidebar-mini', 'sidebar-collapse'], + 'layout' => ['sidebar-mini', 'sidebar-collapse'], /* * Version displayed in footer. */ - 'version' => '1.5.x-dev', + 'version' => '1.5.x-dev', /* * Settings for extensions. diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 8a10beacda..ff372b5f2e 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -97,10 +97,10 @@ 'current_page' => 'Current page', 'selected_rows' => 'Selected rows', - 'upload' => 'Upload', - 'new_folder' => 'New folder', - 'time' => 'Time', - 'size' => 'Size', + 'upload' => 'Upload', + 'new_folder' => 'New folder', + 'time' => 'Time', + 'size' => 'Size', 'listbox' => [ 'text_total' => 'Showing all {0}', diff --git a/resources/lang/zh-CN/admin.php b/resources/lang/zh-CN/admin.php index c59fd1bfbd..3fd7980bc3 100644 --- a/resources/lang/zh-CN/admin.php +++ b/resources/lang/zh-CN/admin.php @@ -97,10 +97,10 @@ 'current_page' => '当前页', 'selected_rows' => '选择的行', - 'upload' => '上传', - 'new_folder' => '新建文件夹', - 'time' => '时间', - 'size' => '大小', + 'upload' => '上传', + 'new_folder' => '新建文件夹', + 'time' => '时间', + 'size' => '大小', 'listbox' => [ 'text_total' => '总共 {0} 项', diff --git a/src/Admin.php b/src/Admin.php index 7fd4dab713..329bd1d184 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -230,9 +230,9 @@ public function getNavbar() public function registerAuthRoutes() { $attributes = [ - 'prefix' => config('admin.route.prefix'), - 'namespace' => 'Encore\Admin\Controllers', - 'middleware' => config('admin.route.middleware'), + 'prefix' => config('admin.route.prefix'), + 'namespace' => 'Encore\Admin\Controllers', + 'middleware' => config('admin.route.middleware'), ]; Route::group($attributes, function ($router) { diff --git a/src/AdminServiceProvider.php b/src/AdminServiceProvider.php index ee9cbc4896..d7da43ef48 100644 --- a/src/AdminServiceProvider.php +++ b/src/AdminServiceProvider.php @@ -23,11 +23,11 @@ class AdminServiceProvider extends ServiceProvider * @var array */ protected $routeMiddleware = [ - 'admin.auth' => \Encore\Admin\Middleware\Authenticate::class, - 'admin.pjax' => \Encore\Admin\Middleware\Pjax::class, - 'admin.log' => \Encore\Admin\Middleware\LogOperation::class, - 'admin.permission' => \Encore\Admin\Middleware\Permission::class, - 'admin.bootstrap' => \Encore\Admin\Middleware\Bootstrap::class, + 'admin.auth' => \Encore\Admin\Middleware\Authenticate::class, + 'admin.pjax' => \Encore\Admin\Middleware\Pjax::class, + 'admin.log' => \Encore\Admin\Middleware\LogOperation::class, + 'admin.permission' => \Encore\Admin\Middleware\Permission::class, + 'admin.bootstrap' => \Encore\Admin\Middleware\Bootstrap::class, ]; /** diff --git a/src/Auth/Database/AdminTablesSeeder.php b/src/Auth/Database/AdminTablesSeeder.php index 1908f71a30..f18823ac39 100644 --- a/src/Auth/Database/AdminTablesSeeder.php +++ b/src/Auth/Database/AdminTablesSeeder.php @@ -16,16 +16,16 @@ public function run() // create a user. Administrator::truncate(); Administrator::create([ - 'username' => 'admin', - 'password' => bcrypt('admin'), - 'name' => 'Administrator', + 'username' => 'admin', + 'password' => bcrypt('admin'), + 'name' => 'Administrator', ]); // create a role. Role::truncate(); Role::create([ - 'name' => 'Administrator', - 'slug' => 'administrator', + 'name' => 'Administrator', + 'slug' => 'administrator', ]); // add role to user. diff --git a/src/Auth/Database/OperationLog.php b/src/Auth/Database/OperationLog.php index ed6931554f..a1437c40ed 100644 --- a/src/Auth/Database/OperationLog.php +++ b/src/Auth/Database/OperationLog.php @@ -10,10 +10,10 @@ class OperationLog extends Model protected $fillable = ['user_id', 'path', 'method', 'ip', 'input']; public static $methodColors = [ - 'GET' => 'green', - 'POST' => 'yellow', - 'PUT' => 'blue', - 'DELETE' => 'red', + 'GET' => 'green', + 'POST' => 'yellow', + 'PUT' => 'blue', + 'DELETE' => 'red', ]; public static $methods = [ diff --git a/src/Exception/Handler.php b/src/Exception/Handler.php index 34126f7b21..361f0b98da 100644 --- a/src/Exception/Handler.php +++ b/src/Exception/Handler.php @@ -17,10 +17,10 @@ class Handler public static function renderException(\Exception $exception) { $error = new MessageBag([ - 'type' => get_class($exception), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), ]); $errors = new ViewErrorBag(); diff --git a/src/Extension.php b/src/Extension.php index dd2c3e2b72..10c28d62d9 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -49,9 +49,9 @@ protected static function createMenu($title, $uri, $icon = 'fa-bars', $parentId protected static function createPermission($name, $slug, $path) { Permission::create([ - 'name' => $name, - 'slug' => $slug, - 'http_path' => '/'.trim($path, '/'), + 'name' => $name, + 'slug' => $slug, + 'http_path' => '/'.trim($path, '/'), ]); } } diff --git a/src/Form.php b/src/Form.php index 704e2bd65f..3b91cd3b52 100644 --- a/src/Form.php +++ b/src/Form.php @@ -1198,52 +1198,52 @@ public function input($key, $value = null) public static function registerBuiltinFields() { $map = [ - 'button' => \Encore\Admin\Form\Field\Button::class, - 'checkbox' => \Encore\Admin\Form\Field\Checkbox::class, - 'color' => \Encore\Admin\Form\Field\Color::class, - 'currency' => \Encore\Admin\Form\Field\Currency::class, - 'date' => \Encore\Admin\Form\Field\Date::class, - 'dateRange' => \Encore\Admin\Form\Field\DateRange::class, - 'datetime' => \Encore\Admin\Form\Field\Datetime::class, - 'dateTimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, - 'datetimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, - 'decimal' => \Encore\Admin\Form\Field\Decimal::class, - 'display' => \Encore\Admin\Form\Field\Display::class, - 'divider' => \Encore\Admin\Form\Field\Divide::class, - 'divide' => \Encore\Admin\Form\Field\Divide::class, - 'embeds' => \Encore\Admin\Form\Field\Embeds::class, - 'editor' => \Encore\Admin\Form\Field\Editor::class, - 'email' => \Encore\Admin\Form\Field\Email::class, - 'file' => \Encore\Admin\Form\Field\File::class, - 'hasMany' => \Encore\Admin\Form\Field\HasMany::class, - 'hidden' => \Encore\Admin\Form\Field\Hidden::class, - 'id' => \Encore\Admin\Form\Field\Id::class, - 'image' => \Encore\Admin\Form\Field\Image::class, - 'ip' => \Encore\Admin\Form\Field\Ip::class, - 'map' => \Encore\Admin\Form\Field\Map::class, - 'mobile' => \Encore\Admin\Form\Field\Mobile::class, - 'month' => \Encore\Admin\Form\Field\Month::class, - 'multipleSelect' => \Encore\Admin\Form\Field\MultipleSelect::class, - 'number' => \Encore\Admin\Form\Field\Number::class, - 'password' => \Encore\Admin\Form\Field\Password::class, - 'radio' => \Encore\Admin\Form\Field\Radio::class, - 'rate' => \Encore\Admin\Form\Field\Rate::class, - 'select' => \Encore\Admin\Form\Field\Select::class, - 'slider' => \Encore\Admin\Form\Field\Slider::class, - 'switch' => \Encore\Admin\Form\Field\SwitchField::class, - 'text' => \Encore\Admin\Form\Field\Text::class, - 'textarea' => \Encore\Admin\Form\Field\Textarea::class, - 'time' => \Encore\Admin\Form\Field\Time::class, - 'timeRange' => \Encore\Admin\Form\Field\TimeRange::class, - 'url' => \Encore\Admin\Form\Field\Url::class, - 'year' => \Encore\Admin\Form\Field\Year::class, - 'html' => \Encore\Admin\Form\Field\Html::class, - 'tags' => \Encore\Admin\Form\Field\Tags::class, - 'icon' => \Encore\Admin\Form\Field\Icon::class, - 'multipleFile' => \Encore\Admin\Form\Field\MultipleFile::class, - 'multipleImage' => \Encore\Admin\Form\Field\MultipleImage::class, - 'captcha' => \Encore\Admin\Form\Field\Captcha::class, - 'listbox' => \Encore\Admin\Form\Field\Listbox::class, + 'button' => \Encore\Admin\Form\Field\Button::class, + 'checkbox' => \Encore\Admin\Form\Field\Checkbox::class, + 'color' => \Encore\Admin\Form\Field\Color::class, + 'currency' => \Encore\Admin\Form\Field\Currency::class, + 'date' => \Encore\Admin\Form\Field\Date::class, + 'dateRange' => \Encore\Admin\Form\Field\DateRange::class, + 'datetime' => \Encore\Admin\Form\Field\Datetime::class, + 'dateTimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, + 'datetimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, + 'decimal' => \Encore\Admin\Form\Field\Decimal::class, + 'display' => \Encore\Admin\Form\Field\Display::class, + 'divider' => \Encore\Admin\Form\Field\Divide::class, + 'divide' => \Encore\Admin\Form\Field\Divide::class, + 'embeds' => \Encore\Admin\Form\Field\Embeds::class, + 'editor' => \Encore\Admin\Form\Field\Editor::class, + 'email' => \Encore\Admin\Form\Field\Email::class, + 'file' => \Encore\Admin\Form\Field\File::class, + 'hasMany' => \Encore\Admin\Form\Field\HasMany::class, + 'hidden' => \Encore\Admin\Form\Field\Hidden::class, + 'id' => \Encore\Admin\Form\Field\Id::class, + 'image' => \Encore\Admin\Form\Field\Image::class, + 'ip' => \Encore\Admin\Form\Field\Ip::class, + 'map' => \Encore\Admin\Form\Field\Map::class, + 'mobile' => \Encore\Admin\Form\Field\Mobile::class, + 'month' => \Encore\Admin\Form\Field\Month::class, + 'multipleSelect' => \Encore\Admin\Form\Field\MultipleSelect::class, + 'number' => \Encore\Admin\Form\Field\Number::class, + 'password' => \Encore\Admin\Form\Field\Password::class, + 'radio' => \Encore\Admin\Form\Field\Radio::class, + 'rate' => \Encore\Admin\Form\Field\Rate::class, + 'select' => \Encore\Admin\Form\Field\Select::class, + 'slider' => \Encore\Admin\Form\Field\Slider::class, + 'switch' => \Encore\Admin\Form\Field\SwitchField::class, + 'text' => \Encore\Admin\Form\Field\Text::class, + 'textarea' => \Encore\Admin\Form\Field\Textarea::class, + 'time' => \Encore\Admin\Form\Field\Time::class, + 'timeRange' => \Encore\Admin\Form\Field\TimeRange::class, + 'url' => \Encore\Admin\Form\Field\Url::class, + 'year' => \Encore\Admin\Form\Field\Year::class, + 'html' => \Encore\Admin\Form\Field\Html::class, + 'tags' => \Encore\Admin\Form\Field\Tags::class, + 'icon' => \Encore\Admin\Form\Field\Icon::class, + 'multipleFile' => \Encore\Admin\Form\Field\MultipleFile::class, + 'multipleImage' => \Encore\Admin\Form\Field\MultipleImage::class, + 'captcha' => \Encore\Admin\Form\Field\Captcha::class, + 'listbox' => \Encore\Admin\Form\Field\Listbox::class, ]; foreach ($map as $abstract => $class) { diff --git a/src/Form/Builder.php b/src/Form/Builder.php index 6f9b5fdd6e..658fddae93 100644 --- a/src/Form/Builder.php +++ b/src/Form/Builder.php @@ -534,9 +534,9 @@ public function render() } $data = [ - 'form' => $this, - 'tabObj' => $tabObj, - 'width' => $this->width, + 'form' => $this, + 'tabObj' => $tabObj, + 'width' => $this->width, ]; return view($this->view, $data)->render(); diff --git a/src/Form/Field.php b/src/Form/Field.php index 7998e42b3f..55550b7bbf 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -730,7 +730,7 @@ public function getViewElementClasses() ]; } - return ['label' =>'', 'field' => '', 'form-group' => '']; + return ['label' => '', 'field' => '', 'form-group' => '']; } /** @@ -857,17 +857,17 @@ public function removeElementClass($class) protected function variables() { return array_merge($this->variables, [ - 'id' => $this->id, - 'name' => $this->elementName ?: $this->formatName($this->column), - 'help' => $this->help, - 'class' => $this->getElementClassString(), - 'value' => $this->value(), - 'label' => $this->label, - 'viewClass' => $this->getViewElementClasses(), - 'column' => $this->column, - 'errorKey' => $this->getErrorKey(), - 'attributes' => $this->formatAttributes(), - 'placeholder' => $this->getPlaceholder(), + 'id' => $this->id, + 'name' => $this->elementName ?: $this->formatName($this->column), + 'help' => $this->help, + 'class' => $this->getElementClassString(), + 'value' => $this->value(), + 'label' => $this->label, + 'viewClass' => $this->getViewElementClasses(), + 'column' => $this->column, + 'errorKey' => $this->getErrorKey(), + 'attributes' => $this->formatAttributes(), + 'placeholder' => $this->getPlaceholder(), ]); } diff --git a/src/Form/Field/Currency.php b/src/Form/Field/Currency.php index 7d05f1a9aa..d22a16f855 100644 --- a/src/Form/Field/Currency.php +++ b/src/Form/Field/Currency.php @@ -16,10 +16,10 @@ class Currency extends Text * @var array */ protected $options = [ - 'alias' => 'currency', - 'radixPoint' => '.', - 'prefix' => '', - 'removeMaskOnSubmit' => true, + 'alias' => 'currency', + 'radixPoint' => '.', + 'prefix' => '', + 'removeMaskOnSubmit' => true, ]; public function symbol($symbol) diff --git a/src/Form/Field/HasMany.php b/src/Form/Field/HasMany.php index e8f4460577..44ada2d9fa 100644 --- a/src/Form/Field/HasMany.php +++ b/src/Form/Field/HasMany.php @@ -52,8 +52,8 @@ class HasMany extends Field * @var array */ protected $views = [ - 'default' => 'admin::form.hasmany', - 'tab' => 'admin::form.hasmanytab', + 'default' => 'admin::form.hasmany', + 'tab' => 'admin::form.hasmanytab', ]; /** @@ -496,9 +496,9 @@ public function render() $this->setupScript($script); return parent::render()->with([ - 'forms' => $this->buildRelatedForms(), - 'template' => $template, - 'relationName' => $this->relationName, + 'forms' => $this->buildRelatedForms(), + 'template' => $template, + 'relationName' => $this->relationName, ]); } } diff --git a/src/Form/Field/MultipleFile.php b/src/Form/Field/MultipleFile.php index a5e9f7e8f5..996f2216ec 100644 --- a/src/Form/Field/MultipleFile.php +++ b/src/Form/Field/MultipleFile.php @@ -208,7 +208,7 @@ public function render() $this->setupDefaultOptions(); if (!empty($this->value)) { - $this->options(['initialPreview' =>$this->preview()]); + $this->options(['initialPreview' => $this->preview()]); $this->setupPreviewOptions(); } diff --git a/src/Form/Field/UploadField.php b/src/Form/Field/UploadField.php index 5909e7eda8..60d46ca231 100644 --- a/src/Form/Field/UploadField.php +++ b/src/Form/Field/UploadField.php @@ -67,7 +67,7 @@ protected function setupDefaultOptions() 'showRemove' => false, 'showUpload' => false, // 'initialCaption' => $this->initialCaption($this->value), - 'deleteExtraData' => [ + 'deleteExtraData' => [ $this->formatName($this->column) => static::FILE_DELETE_FLAG, static::FILE_DELETE_FLAG => '', '_token' => csrf_token(), @@ -95,7 +95,7 @@ protected function setupPreviewOptions() $this->options([ //'initialPreview' => $this->preview(), - 'initialPreviewConfig' => $this->initialPreviewConfig(), + 'initialPreviewConfig' => $this->initialPreviewConfig(), ]); } diff --git a/src/Grid.php b/src/Grid.php index e6044a163f..70c3e786af 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -158,12 +158,12 @@ class Grid * @var array */ protected $options = [ - 'usePagination' => true, - 'useFilter' => true, - 'useExporter' => true, - 'useActions' => true, - 'useRowSelector' => true, - 'allowCreate' => true, + 'usePagination' => true, + 'useFilter' => true, + 'useExporter' => true, + 'useActions' => true, + 'useRowSelector' => true, + 'allowCreate' => true, ]; /** @@ -895,19 +895,19 @@ public function __call($method, $arguments) public static function registerColumnDisplayer() { $map = [ - 'editable' => \Encore\Admin\Grid\Displayers\Editable::class, - 'switch' => \Encore\Admin\Grid\Displayers\SwitchDisplay::class, - 'switchGroup' => \Encore\Admin\Grid\Displayers\SwitchGroup::class, - 'select' => \Encore\Admin\Grid\Displayers\Select::class, - 'image' => \Encore\Admin\Grid\Displayers\Image::class, - 'label' => \Encore\Admin\Grid\Displayers\Label::class, - 'button' => \Encore\Admin\Grid\Displayers\Button::class, - 'link' => \Encore\Admin\Grid\Displayers\Link::class, - 'badge' => \Encore\Admin\Grid\Displayers\Badge::class, - 'progressBar' => \Encore\Admin\Grid\Displayers\ProgressBar::class, - 'radio' => \Encore\Admin\Grid\Displayers\Radio::class, - 'checkbox' => \Encore\Admin\Grid\Displayers\Checkbox::class, - 'orderable' => \Encore\Admin\Grid\Displayers\Orderable::class, + 'editable' => \Encore\Admin\Grid\Displayers\Editable::class, + 'switch' => \Encore\Admin\Grid\Displayers\SwitchDisplay::class, + 'switchGroup' => \Encore\Admin\Grid\Displayers\SwitchGroup::class, + 'select' => \Encore\Admin\Grid\Displayers\Select::class, + 'image' => \Encore\Admin\Grid\Displayers\Image::class, + 'label' => \Encore\Admin\Grid\Displayers\Label::class, + 'button' => \Encore\Admin\Grid\Displayers\Button::class, + 'link' => \Encore\Admin\Grid\Displayers\Link::class, + 'badge' => \Encore\Admin\Grid\Displayers\Badge::class, + 'progressBar' => \Encore\Admin\Grid\Displayers\ProgressBar::class, + 'radio' => \Encore\Admin\Grid\Displayers\Radio::class, + 'checkbox' => \Encore\Admin\Grid\Displayers\Checkbox::class, + 'orderable' => \Encore\Admin\Grid\Displayers\Orderable::class, ]; foreach ($map as $abstract => $class) { diff --git a/src/Grid/Displayers/Editable.php b/src/Grid/Displayers/Editable.php index abef1d86c8..89a292e816 100644 --- a/src/Grid/Displayers/Editable.php +++ b/src/Grid/Displayers/Editable.php @@ -118,10 +118,10 @@ public function combodate($format = 'YYYY-MM-DD') $this->type = 'combodate'; $this->addOptions([ - 'format' => $format, - 'viewformat' => $format, - 'template' => $format, - 'combodate' => [ + 'format' => $format, + 'viewformat' => $format, + 'template' => $format, + 'combodate' => [ 'maxYear' => 2035, ], ]); diff --git a/src/Grid/Filter.php b/src/Grid/Filter.php index 9c1dc56535..0609cb21fd 100644 --- a/src/Grid/Filter.php +++ b/src/Grid/Filter.php @@ -215,8 +215,8 @@ public function render() Admin::script($script); return view($this->view)->with([ - 'action' => $this->action ?: $this->urlWithoutFilters(), - 'filters' => $this->filters, + 'action' => $this->action ?: $this->urlWithoutFilters(), + 'filters' => $this->filters, ]); } diff --git a/src/Grid/Filter/Presenter/Text.php b/src/Grid/Filter/Presenter/Text.php index bd76abc4ac..e876390bbd 100644 --- a/src/Grid/Filter/Presenter/Text.php +++ b/src/Grid/Filter/Presenter/Text.php @@ -105,9 +105,9 @@ public function decimal($options = []) : Text public function currency($options = []) : Text { return $this->inputmask(array_merge($options, [ - 'alias' => 'currency', - 'prefix' => '', - 'removeMaskOnSubmit' => true, + 'alias' => 'currency', + 'prefix' => '', + 'removeMaskOnSubmit' => true, ])); } diff --git a/src/Middleware/Pjax.php b/src/Middleware/Pjax.php index 6463f85b14..c94efcd966 100644 --- a/src/Middleware/Pjax.php +++ b/src/Middleware/Pjax.php @@ -68,10 +68,10 @@ protected function handleErrorResponse(Response $response) $exception = $response->exception; $error = new MessageBag([ - 'type' => get_class($exception), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), ]); return back()->withInput()->withErrors($error, 'exception'); diff --git a/src/Tree.php b/src/Tree.php index bdce65a954..08a861bcae 100644 --- a/src/Tree.php +++ b/src/Tree.php @@ -35,8 +35,8 @@ class Tree implements Renderable * @var string */ protected $view = [ - 'tree' => 'admin::tree', - 'branch' => 'admin::tree.branch', + 'tree' => 'admin::tree', + 'branch' => 'admin::tree.branch', ]; /** @@ -327,12 +327,12 @@ public function getItems() public function variables() { return [ - 'id' => $this->elementId, - 'tools' => $this->tools->render(), - 'items' => $this->getItems(), - 'useCreate' => $this->useCreate, - 'useSave' => $this->useSave, - 'useRefresh'=> $this->useRefresh, + 'id' => $this->elementId, + 'tools' => $this->tools->render(), + 'items' => $this->getItems(), + 'useCreate' => $this->useCreate, + 'useSave' => $this->useSave, + 'useRefresh' => $this->useRefresh, ]; } diff --git a/src/Widgets/Alert.php b/src/Widgets/Alert.php index 58eac2df54..fa59057c14 100644 --- a/src/Widgets/Alert.php +++ b/src/Widgets/Alert.php @@ -83,10 +83,10 @@ protected function variables() $this->class("alert alert-{$this->style} alert-dismissable"); return [ - 'title' => $this->title, - 'content' => $this->content, - 'icon' => $this->icon, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'icon' => $this->icon, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Box.php b/src/Widgets/Box.php index 517e418e71..c8f963eb38 100644 --- a/src/Widgets/Box.php +++ b/src/Widgets/Box.php @@ -143,10 +143,10 @@ public function solid() protected function variables() { return [ - 'title' => $this->title, - 'content' => $this->content, - 'tools' => $this->tools, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'tools' => $this->tools, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Callout.php b/src/Widgets/Callout.php index 3d3a7a32f9..ae5aee1f1b 100644 --- a/src/Widgets/Callout.php +++ b/src/Widgets/Callout.php @@ -64,9 +64,9 @@ protected function variables() $this->class("callout callout-{$this->style}"); return [ - 'title' => $this->title, - 'content' => $this->content, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Carousel.php b/src/Widgets/Carousel.php index d1cca89368..e50a0a6d0f 100644 --- a/src/Widgets/Carousel.php +++ b/src/Widgets/Carousel.php @@ -53,9 +53,9 @@ public function title($title) public function render() { $variables = [ - 'items' => $this->items, - 'title' => $this->title, - 'attributes' => $this->formatAttributes(), + 'items' => $this->items, + 'title' => $this->title, + 'attributes' => $this->formatAttributes(), ]; return view($this->view, $variables)->render(); diff --git a/src/Widgets/Collapse.php b/src/Widgets/Collapse.php index 4108b19a0d..d08b2d0198 100644 --- a/src/Widgets/Collapse.php +++ b/src/Widgets/Collapse.php @@ -47,9 +47,9 @@ public function add($title, $content) protected function variables() { return [ - 'id' => $this->id, - 'items' => $this->items, - 'attributes' => $this->formatAttributes(), + 'id' => $this->id, + 'items' => $this->items, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Form.php b/src/Widgets/Form.php index 77777e3672..59e96b277f 100644 --- a/src/Widgets/Form.php +++ b/src/Widgets/Form.php @@ -214,8 +214,8 @@ protected function getVariables() } return [ - 'fields' => $this->fields, - 'attributes' => $this->formatAttribute(), + 'fields' => $this->fields, + 'attributes' => $this->formatAttribute(), ]; } diff --git a/src/Widgets/InfoBox.php b/src/Widgets/InfoBox.php index 9bcc01658b..63f43d5271 100644 --- a/src/Widgets/InfoBox.php +++ b/src/Widgets/InfoBox.php @@ -28,10 +28,10 @@ class InfoBox extends Widget implements Renderable public function __construct($name, $icon, $color, $link, $info) { $this->data = [ - 'name' => $name, - 'icon' => $icon, - 'link' => $link, - 'info' => $info, + 'name' => $name, + 'icon' => $icon, + 'link' => $link, + 'info' => $info, ]; $this->class("small-box bg-$color"); diff --git a/src/Widgets/Navbar.php b/src/Widgets/Navbar.php index bf4f599a29..452b15ff55 100644 --- a/src/Widgets/Navbar.php +++ b/src/Widgets/Navbar.php @@ -18,8 +18,8 @@ class Navbar implements Renderable public function __construct() { $this->elements = [ - 'left' => collect(), - 'right' => collect(), + 'left' => collect(), + 'right' => collect(), ]; } diff --git a/src/Widgets/Table.php b/src/Widgets/Table.php index 985258bdea..170899726b 100644 --- a/src/Widgets/Table.php +++ b/src/Widgets/Table.php @@ -101,10 +101,10 @@ public function setStyle($style = []) public function render() { $vars = [ - 'headers' => $this->headers, - 'rows' => $this->rows, - 'style' => $this->style, - 'attributes' => $this->formatAttributes(), + 'headers' => $this->headers, + 'rows' => $this->rows, + 'style' => $this->style, + 'attributes' => $this->formatAttributes(), ]; return view($this->view, $vars)->render(); diff --git a/tests/UserFormTest.php b/tests/UserFormTest.php index 8d74f3398e..cb4e93e6b3 100644 --- a/tests/UserFormTest.php +++ b/tests/UserFormTest.php @@ -46,7 +46,7 @@ public function testSubmitForm() 'password' => '123456', 'password_confirmation' => '123456', //"avatar" => "test.jpg", - 'profile' => [ + 'profile' => [ 'first_name' => 'John', 'last_name' => 'Doe', 'postcode' => '123456', diff --git a/tests/config/admin.php b/tests/config/admin.php index 79da185cbf..f178e976a0 100644 --- a/tests/config/admin.php +++ b/tests/config/admin.php @@ -5,12 +5,12 @@ /* * Laravel-admin name. */ - 'name' => 'Laravel-admin', + 'name' => 'Laravel-admin', /* * Logo in admin panel header. */ - 'logo' => 'Laravel admin', + 'logo' => 'Laravel admin', /* * Mini-logo in admin panel header. @@ -24,9 +24,9 @@ 'prefix' => 'admin', - 'namespace' => 'App\\Admin\\Controllers', + 'namespace' => 'App\\Admin\\Controllers', - 'middleware' => ['web', 'admin'], + 'middleware' => ['web', 'admin'], ], /* @@ -37,7 +37,7 @@ /* * Laravel-admin html title. */ - 'title' => 'Admin', + 'title' => 'Admin', /* * Use `https`. @@ -66,13 +66,13 @@ /* * Laravel-admin upload setting. */ - 'upload' => [ + 'upload' => [ 'disk' => 'admin', - 'directory' => [ - 'image' => 'images', - 'file' => 'files', + 'directory' => [ + 'image' => 'images', + 'file' => 'files', ], ], @@ -82,7 +82,7 @@ 'database' => [ // Database connection for following tables. - 'connection' => '', + 'connection' => '', // User tables and model. 'users_table' => 'admin_users', @@ -97,8 +97,8 @@ 'permissions_model' => Encore\Admin\Auth\Database\Permission::class, // Menu table and model. - 'menu_table' => 'admin_menu', - 'menu_model' => Encore\Admin\Auth\Database\Menu::class, + 'menu_table' => 'admin_menu', + 'menu_model' => Encore\Admin\Auth\Database\Menu::class, // Pivot table for table above. 'operation_log_table' => 'admin_operation_log', @@ -111,7 +111,7 @@ /* * By setting this option to open or close operation log in laravel-admin. */ - 'operation_log' => [ + 'operation_log' => [ 'enable' => true, @@ -129,7 +129,7 @@ /* * @see https://adminlte.io/docs/2.4/layout */ - 'skin' => 'skin-blue-light', + 'skin' => 'skin-blue-light', /* |---------------------------------------------------------| @@ -140,12 +140,12 @@ | | sidebar-mini | |---------------------------------------------------------| */ - 'layout' => ['sidebar-mini', 'sidebar-collapse'], + 'layout' => ['sidebar-mini', 'sidebar-collapse'], /* * Version displayed in footer. */ - 'version' => '1.5.x-dev', + 'version' => '1.5.x-dev', /* * Settings for extensions. diff --git a/tests/config/filesystems.php b/tests/config/filesystems.php index 4e6b542c01..4b0a99ea12 100644 --- a/tests/config/filesystems.php +++ b/tests/config/filesystems.php @@ -72,9 +72,9 @@ 'qiniu' => [ 'driver' => 'qiniu', 'domains' => [ - 'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名 - 'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名 - 'custom' => 'static.abc.com', //你的自定义域名 + 'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名 + 'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名 + 'custom' => 'static.abc.com', //你的自定义域名 ], 'access_key' => 'tIyz5h5IDT1-PQS22iRrI4dCBEktWj76O-ls856K', //AccessKey 'secret_key' => 'TCU2GuSlbzxKgnixYO_-pdo4odbXttm1RNNvEwSD', //SecretKey diff --git a/tests/routes.php b/tests/routes.php index d551ed1e22..4a8af18739 100644 --- a/tests/routes.php +++ b/tests/routes.php @@ -1,9 +1,9 @@ config('admin.route.prefix'), - 'namespace' => 'Tests\Controllers', - 'middleware' => ['web', 'admin'], + 'prefix' => config('admin.route.prefix'), + 'namespace' => 'Tests\Controllers', + 'middleware' => ['web', 'admin'], ], function ($router) { $router->resource('images', ImageController::class); $router->resource('multiple-images', MultipleImageController::class); From e7b9738f1a1fca2491b2721f412f8aa815e8e05f Mon Sep 17 00:00:00 2001 From: Thomas Spiessens Date: Tue, 31 Oct 2017 16:01:39 +0100 Subject: [PATCH 0006/1424] Update Filter.php --- src/Grid/Filter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Grid/Filter.php b/src/Grid/Filter.php index 9c1dc56535..a2bcc6c424 100644 --- a/src/Grid/Filter.php +++ b/src/Grid/Filter.php @@ -53,6 +53,13 @@ class Filter */ protected $useIdFilter = true; + /** + * Id filter was removed. + * + * @var bool + */ + protected $idFilterRemoved = false; + /** * Action of search form. * @@ -106,8 +113,9 @@ public function disableIdFilter() */ public function removeIDFilterIfNeeded() { - if (!$this->useIdFilter) { + if (!$this->useIdFilter && !$this->idFilterRemoved) { array_shift($this->filters); + $this->idFilterRemoved = true; } } From 52a8f9ffe647622c10bb0f3b956bb66a08c68f97 Mon Sep 17 00:00:00 2001 From: Song Date: Mon, 6 Nov 2017 02:33:59 +0000 Subject: [PATCH 0007/1424] Apply fixes from StyleCI --- config/admin.php | 32 ++++----- resources/lang/en/admin.php | 8 +-- resources/lang/zh-CN/admin.php | 8 +-- src/Admin.php | 6 +- src/AdminServiceProvider.php | 10 +-- src/Auth/Database/AdminTablesSeeder.php | 10 +-- src/Auth/Database/OperationLog.php | 8 +-- src/Exception/Handler.php | 8 +-- src/Extension.php | 6 +- src/Form.php | 92 ++++++++++++------------- src/Form/Builder.php | 6 +- src/Form/Field.php | 24 +++---- src/Form/Field/Currency.php | 8 +-- src/Form/Field/HasMany.php | 10 +-- src/Form/Field/MultipleFile.php | 2 +- src/Form/Field/Select.php | 5 +- src/Form/Field/UploadField.php | 4 +- src/Grid.php | 38 +++++----- src/Grid/Displayers/Editable.php | 8 +-- src/Grid/Filter.php | 4 +- src/Grid/Filter/Presenter/Radio.php | 2 +- src/Grid/Filter/Presenter/Select.php | 2 +- src/Grid/Filter/Presenter/Text.php | 26 +++---- src/Middleware/Pjax.php | 8 +-- src/Tree.php | 16 ++--- src/Widgets/Alert.php | 8 +-- src/Widgets/Box.php | 8 +-- src/Widgets/Callout.php | 6 +- src/Widgets/Carousel.php | 6 +- src/Widgets/Collapse.php | 6 +- src/Widgets/Form.php | 4 +- src/Widgets/InfoBox.php | 8 +-- src/Widgets/Navbar.php | 4 +- src/Widgets/Table.php | 8 +-- tests/UserFormTest.php | 2 +- tests/config/admin.php | 32 ++++----- tests/config/filesystems.php | 6 +- tests/routes.php | 6 +- 38 files changed, 228 insertions(+), 227 deletions(-) diff --git a/config/admin.php b/config/admin.php index 79da185cbf..f178e976a0 100644 --- a/config/admin.php +++ b/config/admin.php @@ -5,12 +5,12 @@ /* * Laravel-admin name. */ - 'name' => 'Laravel-admin', + 'name' => 'Laravel-admin', /* * Logo in admin panel header. */ - 'logo' => 'Laravel admin', + 'logo' => 'Laravel admin', /* * Mini-logo in admin panel header. @@ -24,9 +24,9 @@ 'prefix' => 'admin', - 'namespace' => 'App\\Admin\\Controllers', + 'namespace' => 'App\\Admin\\Controllers', - 'middleware' => ['web', 'admin'], + 'middleware' => ['web', 'admin'], ], /* @@ -37,7 +37,7 @@ /* * Laravel-admin html title. */ - 'title' => 'Admin', + 'title' => 'Admin', /* * Use `https`. @@ -66,13 +66,13 @@ /* * Laravel-admin upload setting. */ - 'upload' => [ + 'upload' => [ 'disk' => 'admin', - 'directory' => [ - 'image' => 'images', - 'file' => 'files', + 'directory' => [ + 'image' => 'images', + 'file' => 'files', ], ], @@ -82,7 +82,7 @@ 'database' => [ // Database connection for following tables. - 'connection' => '', + 'connection' => '', // User tables and model. 'users_table' => 'admin_users', @@ -97,8 +97,8 @@ 'permissions_model' => Encore\Admin\Auth\Database\Permission::class, // Menu table and model. - 'menu_table' => 'admin_menu', - 'menu_model' => Encore\Admin\Auth\Database\Menu::class, + 'menu_table' => 'admin_menu', + 'menu_model' => Encore\Admin\Auth\Database\Menu::class, // Pivot table for table above. 'operation_log_table' => 'admin_operation_log', @@ -111,7 +111,7 @@ /* * By setting this option to open or close operation log in laravel-admin. */ - 'operation_log' => [ + 'operation_log' => [ 'enable' => true, @@ -129,7 +129,7 @@ /* * @see https://adminlte.io/docs/2.4/layout */ - 'skin' => 'skin-blue-light', + 'skin' => 'skin-blue-light', /* |---------------------------------------------------------| @@ -140,12 +140,12 @@ | | sidebar-mini | |---------------------------------------------------------| */ - 'layout' => ['sidebar-mini', 'sidebar-collapse'], + 'layout' => ['sidebar-mini', 'sidebar-collapse'], /* * Version displayed in footer. */ - 'version' => '1.5.x-dev', + 'version' => '1.5.x-dev', /* * Settings for extensions. diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 8a10beacda..ff372b5f2e 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -97,10 +97,10 @@ 'current_page' => 'Current page', 'selected_rows' => 'Selected rows', - 'upload' => 'Upload', - 'new_folder' => 'New folder', - 'time' => 'Time', - 'size' => 'Size', + 'upload' => 'Upload', + 'new_folder' => 'New folder', + 'time' => 'Time', + 'size' => 'Size', 'listbox' => [ 'text_total' => 'Showing all {0}', diff --git a/resources/lang/zh-CN/admin.php b/resources/lang/zh-CN/admin.php index c59fd1bfbd..3fd7980bc3 100644 --- a/resources/lang/zh-CN/admin.php +++ b/resources/lang/zh-CN/admin.php @@ -97,10 +97,10 @@ 'current_page' => '当前页', 'selected_rows' => '选择的行', - 'upload' => '上传', - 'new_folder' => '新建文件夹', - 'time' => '时间', - 'size' => '大小', + 'upload' => '上传', + 'new_folder' => '新建文件夹', + 'time' => '时间', + 'size' => '大小', 'listbox' => [ 'text_total' => '总共 {0} 项', diff --git a/src/Admin.php b/src/Admin.php index 7fd4dab713..329bd1d184 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -230,9 +230,9 @@ public function getNavbar() public function registerAuthRoutes() { $attributes = [ - 'prefix' => config('admin.route.prefix'), - 'namespace' => 'Encore\Admin\Controllers', - 'middleware' => config('admin.route.middleware'), + 'prefix' => config('admin.route.prefix'), + 'namespace' => 'Encore\Admin\Controllers', + 'middleware' => config('admin.route.middleware'), ]; Route::group($attributes, function ($router) { diff --git a/src/AdminServiceProvider.php b/src/AdminServiceProvider.php index ee9cbc4896..d7da43ef48 100644 --- a/src/AdminServiceProvider.php +++ b/src/AdminServiceProvider.php @@ -23,11 +23,11 @@ class AdminServiceProvider extends ServiceProvider * @var array */ protected $routeMiddleware = [ - 'admin.auth' => \Encore\Admin\Middleware\Authenticate::class, - 'admin.pjax' => \Encore\Admin\Middleware\Pjax::class, - 'admin.log' => \Encore\Admin\Middleware\LogOperation::class, - 'admin.permission' => \Encore\Admin\Middleware\Permission::class, - 'admin.bootstrap' => \Encore\Admin\Middleware\Bootstrap::class, + 'admin.auth' => \Encore\Admin\Middleware\Authenticate::class, + 'admin.pjax' => \Encore\Admin\Middleware\Pjax::class, + 'admin.log' => \Encore\Admin\Middleware\LogOperation::class, + 'admin.permission' => \Encore\Admin\Middleware\Permission::class, + 'admin.bootstrap' => \Encore\Admin\Middleware\Bootstrap::class, ]; /** diff --git a/src/Auth/Database/AdminTablesSeeder.php b/src/Auth/Database/AdminTablesSeeder.php index 1908f71a30..f18823ac39 100644 --- a/src/Auth/Database/AdminTablesSeeder.php +++ b/src/Auth/Database/AdminTablesSeeder.php @@ -16,16 +16,16 @@ public function run() // create a user. Administrator::truncate(); Administrator::create([ - 'username' => 'admin', - 'password' => bcrypt('admin'), - 'name' => 'Administrator', + 'username' => 'admin', + 'password' => bcrypt('admin'), + 'name' => 'Administrator', ]); // create a role. Role::truncate(); Role::create([ - 'name' => 'Administrator', - 'slug' => 'administrator', + 'name' => 'Administrator', + 'slug' => 'administrator', ]); // add role to user. diff --git a/src/Auth/Database/OperationLog.php b/src/Auth/Database/OperationLog.php index ed6931554f..a1437c40ed 100644 --- a/src/Auth/Database/OperationLog.php +++ b/src/Auth/Database/OperationLog.php @@ -10,10 +10,10 @@ class OperationLog extends Model protected $fillable = ['user_id', 'path', 'method', 'ip', 'input']; public static $methodColors = [ - 'GET' => 'green', - 'POST' => 'yellow', - 'PUT' => 'blue', - 'DELETE' => 'red', + 'GET' => 'green', + 'POST' => 'yellow', + 'PUT' => 'blue', + 'DELETE' => 'red', ]; public static $methods = [ diff --git a/src/Exception/Handler.php b/src/Exception/Handler.php index 34126f7b21..361f0b98da 100644 --- a/src/Exception/Handler.php +++ b/src/Exception/Handler.php @@ -17,10 +17,10 @@ class Handler public static function renderException(\Exception $exception) { $error = new MessageBag([ - 'type' => get_class($exception), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), ]); $errors = new ViewErrorBag(); diff --git a/src/Extension.php b/src/Extension.php index dd2c3e2b72..10c28d62d9 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -49,9 +49,9 @@ protected static function createMenu($title, $uri, $icon = 'fa-bars', $parentId protected static function createPermission($name, $slug, $path) { Permission::create([ - 'name' => $name, - 'slug' => $slug, - 'http_path' => '/'.trim($path, '/'), + 'name' => $name, + 'slug' => $slug, + 'http_path' => '/'.trim($path, '/'), ]); } } diff --git a/src/Form.php b/src/Form.php index 704e2bd65f..3b91cd3b52 100644 --- a/src/Form.php +++ b/src/Form.php @@ -1198,52 +1198,52 @@ public function input($key, $value = null) public static function registerBuiltinFields() { $map = [ - 'button' => \Encore\Admin\Form\Field\Button::class, - 'checkbox' => \Encore\Admin\Form\Field\Checkbox::class, - 'color' => \Encore\Admin\Form\Field\Color::class, - 'currency' => \Encore\Admin\Form\Field\Currency::class, - 'date' => \Encore\Admin\Form\Field\Date::class, - 'dateRange' => \Encore\Admin\Form\Field\DateRange::class, - 'datetime' => \Encore\Admin\Form\Field\Datetime::class, - 'dateTimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, - 'datetimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, - 'decimal' => \Encore\Admin\Form\Field\Decimal::class, - 'display' => \Encore\Admin\Form\Field\Display::class, - 'divider' => \Encore\Admin\Form\Field\Divide::class, - 'divide' => \Encore\Admin\Form\Field\Divide::class, - 'embeds' => \Encore\Admin\Form\Field\Embeds::class, - 'editor' => \Encore\Admin\Form\Field\Editor::class, - 'email' => \Encore\Admin\Form\Field\Email::class, - 'file' => \Encore\Admin\Form\Field\File::class, - 'hasMany' => \Encore\Admin\Form\Field\HasMany::class, - 'hidden' => \Encore\Admin\Form\Field\Hidden::class, - 'id' => \Encore\Admin\Form\Field\Id::class, - 'image' => \Encore\Admin\Form\Field\Image::class, - 'ip' => \Encore\Admin\Form\Field\Ip::class, - 'map' => \Encore\Admin\Form\Field\Map::class, - 'mobile' => \Encore\Admin\Form\Field\Mobile::class, - 'month' => \Encore\Admin\Form\Field\Month::class, - 'multipleSelect' => \Encore\Admin\Form\Field\MultipleSelect::class, - 'number' => \Encore\Admin\Form\Field\Number::class, - 'password' => \Encore\Admin\Form\Field\Password::class, - 'radio' => \Encore\Admin\Form\Field\Radio::class, - 'rate' => \Encore\Admin\Form\Field\Rate::class, - 'select' => \Encore\Admin\Form\Field\Select::class, - 'slider' => \Encore\Admin\Form\Field\Slider::class, - 'switch' => \Encore\Admin\Form\Field\SwitchField::class, - 'text' => \Encore\Admin\Form\Field\Text::class, - 'textarea' => \Encore\Admin\Form\Field\Textarea::class, - 'time' => \Encore\Admin\Form\Field\Time::class, - 'timeRange' => \Encore\Admin\Form\Field\TimeRange::class, - 'url' => \Encore\Admin\Form\Field\Url::class, - 'year' => \Encore\Admin\Form\Field\Year::class, - 'html' => \Encore\Admin\Form\Field\Html::class, - 'tags' => \Encore\Admin\Form\Field\Tags::class, - 'icon' => \Encore\Admin\Form\Field\Icon::class, - 'multipleFile' => \Encore\Admin\Form\Field\MultipleFile::class, - 'multipleImage' => \Encore\Admin\Form\Field\MultipleImage::class, - 'captcha' => \Encore\Admin\Form\Field\Captcha::class, - 'listbox' => \Encore\Admin\Form\Field\Listbox::class, + 'button' => \Encore\Admin\Form\Field\Button::class, + 'checkbox' => \Encore\Admin\Form\Field\Checkbox::class, + 'color' => \Encore\Admin\Form\Field\Color::class, + 'currency' => \Encore\Admin\Form\Field\Currency::class, + 'date' => \Encore\Admin\Form\Field\Date::class, + 'dateRange' => \Encore\Admin\Form\Field\DateRange::class, + 'datetime' => \Encore\Admin\Form\Field\Datetime::class, + 'dateTimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, + 'datetimeRange' => \Encore\Admin\Form\Field\DatetimeRange::class, + 'decimal' => \Encore\Admin\Form\Field\Decimal::class, + 'display' => \Encore\Admin\Form\Field\Display::class, + 'divider' => \Encore\Admin\Form\Field\Divide::class, + 'divide' => \Encore\Admin\Form\Field\Divide::class, + 'embeds' => \Encore\Admin\Form\Field\Embeds::class, + 'editor' => \Encore\Admin\Form\Field\Editor::class, + 'email' => \Encore\Admin\Form\Field\Email::class, + 'file' => \Encore\Admin\Form\Field\File::class, + 'hasMany' => \Encore\Admin\Form\Field\HasMany::class, + 'hidden' => \Encore\Admin\Form\Field\Hidden::class, + 'id' => \Encore\Admin\Form\Field\Id::class, + 'image' => \Encore\Admin\Form\Field\Image::class, + 'ip' => \Encore\Admin\Form\Field\Ip::class, + 'map' => \Encore\Admin\Form\Field\Map::class, + 'mobile' => \Encore\Admin\Form\Field\Mobile::class, + 'month' => \Encore\Admin\Form\Field\Month::class, + 'multipleSelect' => \Encore\Admin\Form\Field\MultipleSelect::class, + 'number' => \Encore\Admin\Form\Field\Number::class, + 'password' => \Encore\Admin\Form\Field\Password::class, + 'radio' => \Encore\Admin\Form\Field\Radio::class, + 'rate' => \Encore\Admin\Form\Field\Rate::class, + 'select' => \Encore\Admin\Form\Field\Select::class, + 'slider' => \Encore\Admin\Form\Field\Slider::class, + 'switch' => \Encore\Admin\Form\Field\SwitchField::class, + 'text' => \Encore\Admin\Form\Field\Text::class, + 'textarea' => \Encore\Admin\Form\Field\Textarea::class, + 'time' => \Encore\Admin\Form\Field\Time::class, + 'timeRange' => \Encore\Admin\Form\Field\TimeRange::class, + 'url' => \Encore\Admin\Form\Field\Url::class, + 'year' => \Encore\Admin\Form\Field\Year::class, + 'html' => \Encore\Admin\Form\Field\Html::class, + 'tags' => \Encore\Admin\Form\Field\Tags::class, + 'icon' => \Encore\Admin\Form\Field\Icon::class, + 'multipleFile' => \Encore\Admin\Form\Field\MultipleFile::class, + 'multipleImage' => \Encore\Admin\Form\Field\MultipleImage::class, + 'captcha' => \Encore\Admin\Form\Field\Captcha::class, + 'listbox' => \Encore\Admin\Form\Field\Listbox::class, ]; foreach ($map as $abstract => $class) { diff --git a/src/Form/Builder.php b/src/Form/Builder.php index 6f9b5fdd6e..658fddae93 100644 --- a/src/Form/Builder.php +++ b/src/Form/Builder.php @@ -534,9 +534,9 @@ public function render() } $data = [ - 'form' => $this, - 'tabObj' => $tabObj, - 'width' => $this->width, + 'form' => $this, + 'tabObj' => $tabObj, + 'width' => $this->width, ]; return view($this->view, $data)->render(); diff --git a/src/Form/Field.php b/src/Form/Field.php index 7998e42b3f..55550b7bbf 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -730,7 +730,7 @@ public function getViewElementClasses() ]; } - return ['label' =>'', 'field' => '', 'form-group' => '']; + return ['label' => '', 'field' => '', 'form-group' => '']; } /** @@ -857,17 +857,17 @@ public function removeElementClass($class) protected function variables() { return array_merge($this->variables, [ - 'id' => $this->id, - 'name' => $this->elementName ?: $this->formatName($this->column), - 'help' => $this->help, - 'class' => $this->getElementClassString(), - 'value' => $this->value(), - 'label' => $this->label, - 'viewClass' => $this->getViewElementClasses(), - 'column' => $this->column, - 'errorKey' => $this->getErrorKey(), - 'attributes' => $this->formatAttributes(), - 'placeholder' => $this->getPlaceholder(), + 'id' => $this->id, + 'name' => $this->elementName ?: $this->formatName($this->column), + 'help' => $this->help, + 'class' => $this->getElementClassString(), + 'value' => $this->value(), + 'label' => $this->label, + 'viewClass' => $this->getViewElementClasses(), + 'column' => $this->column, + 'errorKey' => $this->getErrorKey(), + 'attributes' => $this->formatAttributes(), + 'placeholder' => $this->getPlaceholder(), ]); } diff --git a/src/Form/Field/Currency.php b/src/Form/Field/Currency.php index 7d05f1a9aa..d22a16f855 100644 --- a/src/Form/Field/Currency.php +++ b/src/Form/Field/Currency.php @@ -16,10 +16,10 @@ class Currency extends Text * @var array */ protected $options = [ - 'alias' => 'currency', - 'radixPoint' => '.', - 'prefix' => '', - 'removeMaskOnSubmit' => true, + 'alias' => 'currency', + 'radixPoint' => '.', + 'prefix' => '', + 'removeMaskOnSubmit' => true, ]; public function symbol($symbol) diff --git a/src/Form/Field/HasMany.php b/src/Form/Field/HasMany.php index e8f4460577..44ada2d9fa 100644 --- a/src/Form/Field/HasMany.php +++ b/src/Form/Field/HasMany.php @@ -52,8 +52,8 @@ class HasMany extends Field * @var array */ protected $views = [ - 'default' => 'admin::form.hasmany', - 'tab' => 'admin::form.hasmanytab', + 'default' => 'admin::form.hasmany', + 'tab' => 'admin::form.hasmanytab', ]; /** @@ -496,9 +496,9 @@ public function render() $this->setupScript($script); return parent::render()->with([ - 'forms' => $this->buildRelatedForms(), - 'template' => $template, - 'relationName' => $this->relationName, + 'forms' => $this->buildRelatedForms(), + 'template' => $template, + 'relationName' => $this->relationName, ]); } } diff --git a/src/Form/Field/MultipleFile.php b/src/Form/Field/MultipleFile.php index a5e9f7e8f5..996f2216ec 100644 --- a/src/Form/Field/MultipleFile.php +++ b/src/Form/Field/MultipleFile.php @@ -208,7 +208,7 @@ public function render() $this->setupDefaultOptions(); if (!empty($this->value)) { - $this->options(['initialPreview' =>$this->preview()]); + $this->options(['initialPreview' => $this->preview()]); $this->setupPreviewOptions(); } diff --git a/src/Form/Field/Select.php b/src/Form/Field/Select.php index 78e329c0a3..49e227891f 100644 --- a/src/Form/Field/Select.php +++ b/src/Form/Field/Select.php @@ -210,12 +210,13 @@ public function ajax($url, $idField = 'id', $textField = 'text') } /** - * Set config for select2 + * Set config for select2. * * all configurations see https://select2.org/configuration/options-api * * @param string $key * @param mixed $val + * * @return $this */ public function config($key, $val) @@ -231,7 +232,7 @@ public function config($key, $val) public function render() { $configs = array_merge([ - 'allowClear' => true, + 'allowClear' => true, 'placeholder' => $this->label, ], $this->config); diff --git a/src/Form/Field/UploadField.php b/src/Form/Field/UploadField.php index 5909e7eda8..60d46ca231 100644 --- a/src/Form/Field/UploadField.php +++ b/src/Form/Field/UploadField.php @@ -67,7 +67,7 @@ protected function setupDefaultOptions() 'showRemove' => false, 'showUpload' => false, // 'initialCaption' => $this->initialCaption($this->value), - 'deleteExtraData' => [ + 'deleteExtraData' => [ $this->formatName($this->column) => static::FILE_DELETE_FLAG, static::FILE_DELETE_FLAG => '', '_token' => csrf_token(), @@ -95,7 +95,7 @@ protected function setupPreviewOptions() $this->options([ //'initialPreview' => $this->preview(), - 'initialPreviewConfig' => $this->initialPreviewConfig(), + 'initialPreviewConfig' => $this->initialPreviewConfig(), ]); } diff --git a/src/Grid.php b/src/Grid.php index e6044a163f..70c3e786af 100644 --- a/src/Grid.php +++ b/src/Grid.php @@ -158,12 +158,12 @@ class Grid * @var array */ protected $options = [ - 'usePagination' => true, - 'useFilter' => true, - 'useExporter' => true, - 'useActions' => true, - 'useRowSelector' => true, - 'allowCreate' => true, + 'usePagination' => true, + 'useFilter' => true, + 'useExporter' => true, + 'useActions' => true, + 'useRowSelector' => true, + 'allowCreate' => true, ]; /** @@ -895,19 +895,19 @@ public function __call($method, $arguments) public static function registerColumnDisplayer() { $map = [ - 'editable' => \Encore\Admin\Grid\Displayers\Editable::class, - 'switch' => \Encore\Admin\Grid\Displayers\SwitchDisplay::class, - 'switchGroup' => \Encore\Admin\Grid\Displayers\SwitchGroup::class, - 'select' => \Encore\Admin\Grid\Displayers\Select::class, - 'image' => \Encore\Admin\Grid\Displayers\Image::class, - 'label' => \Encore\Admin\Grid\Displayers\Label::class, - 'button' => \Encore\Admin\Grid\Displayers\Button::class, - 'link' => \Encore\Admin\Grid\Displayers\Link::class, - 'badge' => \Encore\Admin\Grid\Displayers\Badge::class, - 'progressBar' => \Encore\Admin\Grid\Displayers\ProgressBar::class, - 'radio' => \Encore\Admin\Grid\Displayers\Radio::class, - 'checkbox' => \Encore\Admin\Grid\Displayers\Checkbox::class, - 'orderable' => \Encore\Admin\Grid\Displayers\Orderable::class, + 'editable' => \Encore\Admin\Grid\Displayers\Editable::class, + 'switch' => \Encore\Admin\Grid\Displayers\SwitchDisplay::class, + 'switchGroup' => \Encore\Admin\Grid\Displayers\SwitchGroup::class, + 'select' => \Encore\Admin\Grid\Displayers\Select::class, + 'image' => \Encore\Admin\Grid\Displayers\Image::class, + 'label' => \Encore\Admin\Grid\Displayers\Label::class, + 'button' => \Encore\Admin\Grid\Displayers\Button::class, + 'link' => \Encore\Admin\Grid\Displayers\Link::class, + 'badge' => \Encore\Admin\Grid\Displayers\Badge::class, + 'progressBar' => \Encore\Admin\Grid\Displayers\ProgressBar::class, + 'radio' => \Encore\Admin\Grid\Displayers\Radio::class, + 'checkbox' => \Encore\Admin\Grid\Displayers\Checkbox::class, + 'orderable' => \Encore\Admin\Grid\Displayers\Orderable::class, ]; foreach ($map as $abstract => $class) { diff --git a/src/Grid/Displayers/Editable.php b/src/Grid/Displayers/Editable.php index abef1d86c8..89a292e816 100644 --- a/src/Grid/Displayers/Editable.php +++ b/src/Grid/Displayers/Editable.php @@ -118,10 +118,10 @@ public function combodate($format = 'YYYY-MM-DD') $this->type = 'combodate'; $this->addOptions([ - 'format' => $format, - 'viewformat' => $format, - 'template' => $format, - 'combodate' => [ + 'format' => $format, + 'viewformat' => $format, + 'template' => $format, + 'combodate' => [ 'maxYear' => 2035, ], ]); diff --git a/src/Grid/Filter.php b/src/Grid/Filter.php index a2bcc6c424..43a29ab6c0 100644 --- a/src/Grid/Filter.php +++ b/src/Grid/Filter.php @@ -223,8 +223,8 @@ public function render() Admin::script($script); return view($this->view)->with([ - 'action' => $this->action ?: $this->urlWithoutFilters(), - 'filters' => $this->filters, + 'action' => $this->action ?: $this->urlWithoutFilters(), + 'filters' => $this->filters, ]); } diff --git a/src/Grid/Filter/Presenter/Radio.php b/src/Grid/Filter/Presenter/Radio.php index 77dddd0b87..78a4a0dbc7 100644 --- a/src/Grid/Filter/Presenter/Radio.php +++ b/src/Grid/Filter/Presenter/Radio.php @@ -40,7 +40,7 @@ public function __construct($options = []) * * @return $this */ - public function stacked() : Radio + public function stacked() : self { $this->inline = false; diff --git a/src/Grid/Filter/Presenter/Select.php b/src/Grid/Filter/Presenter/Select.php index 80726190bd..6076736c2e 100644 --- a/src/Grid/Filter/Presenter/Select.php +++ b/src/Grid/Filter/Presenter/Select.php @@ -136,7 +136,7 @@ protected function getElementClass() : string * * @return $this */ - public function load($target, $resourceUrl, $idField = 'id', $textField = 'text') : Select + public function load($target, $resourceUrl, $idField = 'id', $textField = 'text') : self { $column = $this->filter->getColumn(); diff --git a/src/Grid/Filter/Presenter/Text.php b/src/Grid/Filter/Presenter/Text.php index bd76abc4ac..ecd4f7aa2a 100644 --- a/src/Grid/Filter/Presenter/Text.php +++ b/src/Grid/Filter/Presenter/Text.php @@ -52,7 +52,7 @@ public function variables() : array * * @return $this */ - public function placeholder($placeholder = '') : Text + public function placeholder($placeholder = '') : self { $this->placeholder = $placeholder; @@ -62,7 +62,7 @@ public function placeholder($placeholder = '') : Text /** * @return Text */ - public function url() : Text + public function url() : self { return $this->inputmask(['alias' => 'url'], 'internet-explorer'); } @@ -70,7 +70,7 @@ public function url() : Text /** * @return Text */ - public function email() : Text + public function email() : self { return $this->inputmask(['alias' => 'email'], 'envelope'); } @@ -78,7 +78,7 @@ public function email() : Text /** * @return Text */ - public function integer() : Text + public function integer() : self { return $this->inputmask(['alias' => 'integer']); } @@ -90,7 +90,7 @@ public function integer() : Text * * @return Text */ - public function decimal($options = []) : Text + public function decimal($options = []) : self { return $this->inputmask(array_merge($options, ['alias' => 'decimal'])); } @@ -102,12 +102,12 @@ public function decimal($options = []) : Text * * @return Text */ - public function currency($options = []) : Text + public function currency($options = []) : self { return $this->inputmask(array_merge($options, [ - 'alias' => 'currency', - 'prefix' => '', - 'removeMaskOnSubmit' => true, + 'alias' => 'currency', + 'prefix' => '', + 'removeMaskOnSubmit' => true, ])); } @@ -128,7 +128,7 @@ public function percentage($options = []) /** * @return Text */ - public function ip() : Text + public function ip() : self { return $this->inputmask(['alias' => 'ip'], 'laptop'); } @@ -136,7 +136,7 @@ public function ip() : Text /** * @return Text */ - public function mac() : Text + public function mac() : self { return $this->inputmask(['alias' => 'mac'], 'laptop'); } @@ -146,7 +146,7 @@ public function mac() : Text * * @return Text */ - public function mobile($mask = '19999999999') : Text + public function mobile($mask = '19999999999') : self { return $this->inputmask(compact('mask'), 'phone'); } @@ -157,7 +157,7 @@ public function mobile($mask = '19999999999') : Text * * @return $this */ - public function inputmask($options = [], $icon = 'pencil') : Text + public function inputmask($options = [], $icon = 'pencil') : self { $options = json_encode($options); diff --git a/src/Middleware/Pjax.php b/src/Middleware/Pjax.php index 6463f85b14..c94efcd966 100644 --- a/src/Middleware/Pjax.php +++ b/src/Middleware/Pjax.php @@ -68,10 +68,10 @@ protected function handleErrorResponse(Response $response) $exception = $response->exception; $error = new MessageBag([ - 'type' => get_class($exception), - 'message' => $exception->getMessage(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), ]); return back()->withInput()->withErrors($error, 'exception'); diff --git a/src/Tree.php b/src/Tree.php index bdce65a954..08a861bcae 100644 --- a/src/Tree.php +++ b/src/Tree.php @@ -35,8 +35,8 @@ class Tree implements Renderable * @var string */ protected $view = [ - 'tree' => 'admin::tree', - 'branch' => 'admin::tree.branch', + 'tree' => 'admin::tree', + 'branch' => 'admin::tree.branch', ]; /** @@ -327,12 +327,12 @@ public function getItems() public function variables() { return [ - 'id' => $this->elementId, - 'tools' => $this->tools->render(), - 'items' => $this->getItems(), - 'useCreate' => $this->useCreate, - 'useSave' => $this->useSave, - 'useRefresh'=> $this->useRefresh, + 'id' => $this->elementId, + 'tools' => $this->tools->render(), + 'items' => $this->getItems(), + 'useCreate' => $this->useCreate, + 'useSave' => $this->useSave, + 'useRefresh' => $this->useRefresh, ]; } diff --git a/src/Widgets/Alert.php b/src/Widgets/Alert.php index 58eac2df54..fa59057c14 100644 --- a/src/Widgets/Alert.php +++ b/src/Widgets/Alert.php @@ -83,10 +83,10 @@ protected function variables() $this->class("alert alert-{$this->style} alert-dismissable"); return [ - 'title' => $this->title, - 'content' => $this->content, - 'icon' => $this->icon, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'icon' => $this->icon, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Box.php b/src/Widgets/Box.php index 517e418e71..c8f963eb38 100644 --- a/src/Widgets/Box.php +++ b/src/Widgets/Box.php @@ -143,10 +143,10 @@ public function solid() protected function variables() { return [ - 'title' => $this->title, - 'content' => $this->content, - 'tools' => $this->tools, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'tools' => $this->tools, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Callout.php b/src/Widgets/Callout.php index 3d3a7a32f9..ae5aee1f1b 100644 --- a/src/Widgets/Callout.php +++ b/src/Widgets/Callout.php @@ -64,9 +64,9 @@ protected function variables() $this->class("callout callout-{$this->style}"); return [ - 'title' => $this->title, - 'content' => $this->content, - 'attributes' => $this->formatAttributes(), + 'title' => $this->title, + 'content' => $this->content, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Carousel.php b/src/Widgets/Carousel.php index d1cca89368..e50a0a6d0f 100644 --- a/src/Widgets/Carousel.php +++ b/src/Widgets/Carousel.php @@ -53,9 +53,9 @@ public function title($title) public function render() { $variables = [ - 'items' => $this->items, - 'title' => $this->title, - 'attributes' => $this->formatAttributes(), + 'items' => $this->items, + 'title' => $this->title, + 'attributes' => $this->formatAttributes(), ]; return view($this->view, $variables)->render(); diff --git a/src/Widgets/Collapse.php b/src/Widgets/Collapse.php index 4108b19a0d..d08b2d0198 100644 --- a/src/Widgets/Collapse.php +++ b/src/Widgets/Collapse.php @@ -47,9 +47,9 @@ public function add($title, $content) protected function variables() { return [ - 'id' => $this->id, - 'items' => $this->items, - 'attributes' => $this->formatAttributes(), + 'id' => $this->id, + 'items' => $this->items, + 'attributes' => $this->formatAttributes(), ]; } diff --git a/src/Widgets/Form.php b/src/Widgets/Form.php index 77777e3672..59e96b277f 100644 --- a/src/Widgets/Form.php +++ b/src/Widgets/Form.php @@ -214,8 +214,8 @@ protected function getVariables() } return [ - 'fields' => $this->fields, - 'attributes' => $this->formatAttribute(), + 'fields' => $this->fields, + 'attributes' => $this->formatAttribute(), ]; } diff --git a/src/Widgets/InfoBox.php b/src/Widgets/InfoBox.php index 9bcc01658b..63f43d5271 100644 --- a/src/Widgets/InfoBox.php +++ b/src/Widgets/InfoBox.php @@ -28,10 +28,10 @@ class InfoBox extends Widget implements Renderable public function __construct($name, $icon, $color, $link, $info) { $this->data = [ - 'name' => $name, - 'icon' => $icon, - 'link' => $link, - 'info' => $info, + 'name' => $name, + 'icon' => $icon, + 'link' => $link, + 'info' => $info, ]; $this->class("small-box bg-$color"); diff --git a/src/Widgets/Navbar.php b/src/Widgets/Navbar.php index bf4f599a29..452b15ff55 100644 --- a/src/Widgets/Navbar.php +++ b/src/Widgets/Navbar.php @@ -18,8 +18,8 @@ class Navbar implements Renderable public function __construct() { $this->elements = [ - 'left' => collect(), - 'right' => collect(), + 'left' => collect(), + 'right' => collect(), ]; } diff --git a/src/Widgets/Table.php b/src/Widgets/Table.php index 985258bdea..170899726b 100644 --- a/src/Widgets/Table.php +++ b/src/Widgets/Table.php @@ -101,10 +101,10 @@ public function setStyle($style = []) public function render() { $vars = [ - 'headers' => $this->headers, - 'rows' => $this->rows, - 'style' => $this->style, - 'attributes' => $this->formatAttributes(), + 'headers' => $this->headers, + 'rows' => $this->rows, + 'style' => $this->style, + 'attributes' => $this->formatAttributes(), ]; return view($this->view, $vars)->render(); diff --git a/tests/UserFormTest.php b/tests/UserFormTest.php index 8d74f3398e..cb4e93e6b3 100644 --- a/tests/UserFormTest.php +++ b/tests/UserFormTest.php @@ -46,7 +46,7 @@ public function testSubmitForm() 'password' => '123456', 'password_confirmation' => '123456', //"avatar" => "test.jpg", - 'profile' => [ + 'profile' => [ 'first_name' => 'John', 'last_name' => 'Doe', 'postcode' => '123456', diff --git a/tests/config/admin.php b/tests/config/admin.php index 79da185cbf..f178e976a0 100644 --- a/tests/config/admin.php +++ b/tests/config/admin.php @@ -5,12 +5,12 @@ /* * Laravel-admin name. */ - 'name' => 'Laravel-admin', + 'name' => 'Laravel-admin', /* * Logo in admin panel header. */ - 'logo' => 'Laravel admin', + 'logo' => 'Laravel admin', /* * Mini-logo in admin panel header. @@ -24,9 +24,9 @@ 'prefix' => 'admin', - 'namespace' => 'App\\Admin\\Controllers', + 'namespace' => 'App\\Admin\\Controllers', - 'middleware' => ['web', 'admin'], + 'middleware' => ['web', 'admin'], ], /* @@ -37,7 +37,7 @@ /* * Laravel-admin html title. */ - 'title' => 'Admin', + 'title' => 'Admin', /* * Use `https`. @@ -66,13 +66,13 @@ /* * Laravel-admin upload setting. */ - 'upload' => [ + 'upload' => [ 'disk' => 'admin', - 'directory' => [ - 'image' => 'images', - 'file' => 'files', + 'directory' => [ + 'image' => 'images', + 'file' => 'files', ], ], @@ -82,7 +82,7 @@ 'database' => [ // Database connection for following tables. - 'connection' => '', + 'connection' => '', // User tables and model. 'users_table' => 'admin_users', @@ -97,8 +97,8 @@ 'permissions_model' => Encore\Admin\Auth\Database\Permission::class, // Menu table and model. - 'menu_table' => 'admin_menu', - 'menu_model' => Encore\Admin\Auth\Database\Menu::class, + 'menu_table' => 'admin_menu', + 'menu_model' => Encore\Admin\Auth\Database\Menu::class, // Pivot table for table above. 'operation_log_table' => 'admin_operation_log', @@ -111,7 +111,7 @@ /* * By setting this option to open or close operation log in laravel-admin. */ - 'operation_log' => [ + 'operation_log' => [ 'enable' => true, @@ -129,7 +129,7 @@ /* * @see https://adminlte.io/docs/2.4/layout */ - 'skin' => 'skin-blue-light', + 'skin' => 'skin-blue-light', /* |---------------------------------------------------------| @@ -140,12 +140,12 @@ | | sidebar-mini | |---------------------------------------------------------| */ - 'layout' => ['sidebar-mini', 'sidebar-collapse'], + 'layout' => ['sidebar-mini', 'sidebar-collapse'], /* * Version displayed in footer. */ - 'version' => '1.5.x-dev', + 'version' => '1.5.x-dev', /* * Settings for extensions. diff --git a/tests/config/filesystems.php b/tests/config/filesystems.php index 4e6b542c01..4b0a99ea12 100644 --- a/tests/config/filesystems.php +++ b/tests/config/filesystems.php @@ -72,9 +72,9 @@ 'qiniu' => [ 'driver' => 'qiniu', 'domains' => [ - 'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名 - 'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名 - 'custom' => 'static.abc.com', //你的自定义域名 + 'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名 + 'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名 + 'custom' => 'static.abc.com', //你的自定义域名 ], 'access_key' => 'tIyz5h5IDT1-PQS22iRrI4dCBEktWj76O-ls856K', //AccessKey 'secret_key' => 'TCU2GuSlbzxKgnixYO_-pdo4odbXttm1RNNvEwSD', //SecretKey diff --git a/tests/routes.php b/tests/routes.php index d551ed1e22..4a8af18739 100644 --- a/tests/routes.php +++ b/tests/routes.php @@ -1,9 +1,9 @@ config('admin.route.prefix'), - 'namespace' => 'Tests\Controllers', - 'middleware' => ['web', 'admin'], + 'prefix' => config('admin.route.prefix'), + 'namespace' => 'Tests\Controllers', + 'middleware' => ['web', 'admin'], ], function ($router) { $router->resource('images', ImageController::class); $router->resource('multiple-images', MultipleImageController::class); From a871cc2984a0231b0283d4a11600843f070ad235 Mon Sep 17 00:00:00 2001 From: Song Date: Sun, 5 Nov 2017 20:59:46 -0600 Subject: [PATCH 0008/1424] Update README.md --- README.md | 58 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3da55c33d9..800c4c4712 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,42 @@ -laravel-admin -===== - -[![Build Status](https://travis-ci.org/z-song/laravel-admin.svg?branch=master)](https://travis-ci.org/z-song/laravel-admin) -[![StyleCI](https://styleci.io/repos/48796179/shield)](https://styleci.io/repos/48796179) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/z-song/laravel-admin/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/z-song/laravel-admin/?branch=master) -[![Packagist](https://img.shields.io/packagist/l/encore/laravel-admin.svg?maxAge=2592000)](https://packagist.org/packages/encore/laravel-admin) -[![Total Downloads](https://img.shields.io/packagist/dt/encore/laravel-admin.svg?style=flat-square)](https://packagist.org/packages/encore/laravel-admin) -[![Awesome Laravel](https://img.shields.io/badge/Awesome-Laravel-brightgreen.svg)](https://github.com/z-song/laravel-admin) - -`laravel-admin` is administrative interface builder for laravel which can help you build CRUD backends just with few lines of code. - -[Demo](http://laravel-admin.org/demo) - -Inspired by [SleepingOwlAdmin](https://github.com/sleeping-owl/admin) and [rapyd-laravel](https://github.com/zofe/rapyd-laravel). - -[Documentation](http://laravel-admin.org/docs) | [中文文档](http://laravel-admin.org/docs/#/zh/) - -[Extensions](https://github.com/laravel-admin-extensions) +

+ +laravel-admin + + +

laravel-admin is administrative interface builder for laravel which can help you build CRUD backends just with few lines of code.

+ +

+Documentation | +中文文档 | +Demo | +Demo source code | +Extensions +

+ +

+ + Build Status + + + StyleCI + + + Scrutinizer Code Quality + + + Packagist + + + Total Downloads + + + Awesome Laravel + + + +

+ Inspired by SleepingOwlAdmin and rapyd-laravel. +

Screenshots ------------ From 8c8ae1b48f9c42689141e03d6a89549b4f4c2506 Mon Sep 17 00:00:00 2001 From: Song Date: Sun, 5 Nov 2017 21:04:07 -0600 Subject: [PATCH 0009/1424] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 800c4c4712..4a6d02671e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

-laravel-admin +laravel-admin

laravel-admin is administrative interface builder for laravel which can help you build CRUD backends just with few lines of code.

From c9bfea87687ceb8b9b34acafa4192371bb6d6924 Mon Sep 17 00:00:00 2001 From: Song Date: Mon, 6 Nov 2017 03:05:28 +0000 Subject: [PATCH 0010/1424] Apply fixes from StyleCI --- src/Grid/Filter/Presenter/Radio.php | 2 +- src/Grid/Filter/Presenter/Select.php | 2 +- src/Grid/Filter/Presenter/Text.php | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Grid/Filter/Presenter/Radio.php b/src/Grid/Filter/Presenter/Radio.php index 77dddd0b87..78a4a0dbc7 100644 --- a/src/Grid/Filter/Presenter/Radio.php +++ b/src/Grid/Filter/Presenter/Radio.php @@ -40,7 +40,7 @@ public function __construct($options = []) * * @return $this */ - public function stacked() : Radio + public function stacked() : self { $this->inline = false; diff --git a/src/Grid/Filter/Presenter/Select.php b/src/Grid/Filter/Presenter/Select.php index 80726190bd..6076736c2e 100644 --- a/src/Grid/Filter/Presenter/Select.php +++ b/src/Grid/Filter/Presenter/Select.php @@ -136,7 +136,7 @@ protected function getElementClass() : string * * @return $this */ - public function load($target, $resourceUrl, $idField = 'id', $textField = 'text') : Select + public function load($target, $resourceUrl, $idField = 'id', $textField = 'text') : self { $column = $this->filter->getColumn(); diff --git a/src/Grid/Filter/Presenter/Text.php b/src/Grid/Filter/Presenter/Text.php index e876390bbd..ecd4f7aa2a 100644 --- a/src/Grid/Filter/Presenter/Text.php +++ b/src/Grid/Filter/Presenter/Text.php @@ -52,7 +52,7 @@ public function variables() : array * * @return $this */ - public function placeholder($placeholder = '') : Text + public function placeholder($placeholder = '') : self { $this->placeholder = $placeholder; @@ -62,7 +62,7 @@ public function placeholder($placeholder = '') : Text /** * @return Text */ - public function url() : Text + public function url() : self { return $this->inputmask(['alias' => 'url'], 'internet-explorer'); } @@ -70,7 +70,7 @@ public function url() : Text /** * @return Text */ - public function email() : Text + public function email() : self { return $this->inputmask(['alias' => 'email'], 'envelope'); } @@ -78,7 +78,7 @@ public function email() : Text /** * @return Text */ - public function integer() : Text + public function integer() : self { return $this->inputmask(['alias' => 'integer']); } @@ -90,7 +90,7 @@ public function integer() : Text * * @return Text */ - public function decimal($options = []) : Text + public function decimal($options = []) : self { return $this->inputmask(array_merge($options, ['alias' => 'decimal'])); } @@ -102,7 +102,7 @@ public function decimal($options = []) : Text * * @return Text */ - public function currency($options = []) : Text + public function currency($options = []) : self { return $this->inputmask(array_merge($options, [ 'alias' => 'currency', @@ -128,7 +128,7 @@ public function percentage($options = []) /** * @return Text */ - public function ip() : Text + public function ip() : self { return $this->inputmask(['alias' => 'ip'], 'laptop'); } @@ -136,7 +136,7 @@ public function ip() : Text /** * @return Text */ - public function mac() : Text + public function mac() : self { return $this->inputmask(['alias' => 'mac'], 'laptop'); } @@ -146,7 +146,7 @@ public function mac() : Text * * @return Text */ - public function mobile($mask = '19999999999') : Text + public function mobile($mask = '19999999999') : self { return $this->inputmask(compact('mask'), 'phone'); } @@ -157,7 +157,7 @@ public function mobile($mask = '19999999999') : Text * * @return $this */ - public function inputmask($options = [], $icon = 'pencil') : Text + public function inputmask($options = [], $icon = 'pencil') : self { $options = json_encode($options); From 7c50354c446b89bdd470a58371fe5d3d2614d2af Mon Sep 17 00:00:00 2001 From: z-song Date: Wed, 8 Nov 2017 00:03:47 +0800 Subject: [PATCH 0011/1424] fix style conflict --- resources/assets/laravel-admin/laravel-admin.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/assets/laravel-admin/laravel-admin.css b/resources/assets/laravel-admin/laravel-admin.css index e69de29bb2..74574ef47d 100644 --- a/resources/assets/laravel-admin/laravel-admin.css +++ b/resources/assets/laravel-admin/laravel-admin.css @@ -0,0 +1,5 @@ +input.content { + min-height: 0 !important; + padding: 6px 12px !important; + margin: 0 !important; +} \ No newline at end of file From 04335c22b9f81480109e1b92fd681ce69235a869 Mon Sep 17 00:00:00 2001 From: z-song Date: Wed, 8 Nov 2017 00:04:34 +0800 Subject: [PATCH 0012/1424] fix issue #1388, close issue #1388 --- src/Form/Field/Tags.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Form/Field/Tags.php b/src/Form/Field/Tags.php index 8d8435bfd9..70a7d72472 100644 --- a/src/Form/Field/Tags.php +++ b/src/Form/Field/Tags.php @@ -7,16 +7,28 @@ class Tags extends Field { + /** + * @var array + */ protected $value = []; + /** + * @var array + */ protected static $css = [ '/vendor/laravel-admin/AdminLTE/plugins/select2/select2.min.css', ]; + /** + * @var array + */ protected static $js = [ '/vendor/laravel-admin/AdminLTE/plugins/select2/select2.full.min.js', ]; + /** + * {@inheritdoc} + */ public function fill($data) { $this->value = array_get($data, $this->column); @@ -28,6 +40,9 @@ public function fill($data) $this->value = array_filter((array) $this->value); } + /** + * {@inheritdoc} + */ public function prepare($value) { if (is_array($value) && !Arr::isAssoc($value)) { @@ -37,10 +52,16 @@ public function prepare($value) return $value; } + /** + * Get or set value for this field. + * + * @param mixed $value + * @return $this|array|mixed + */ public function value($value = null) { if (is_null($value)) { - return empty($this->value) ? $this->getDefault() : $this->value; + return empty($this->value) ? ($this->getDefault() ?? []) : $this->value; } $this->value = $value; @@ -48,6 +69,9 @@ public function value($value = null) return $this; } + /** + * {@inheritdoc} + */ public function render() { $this->script = "$(\"{$this->getElementClassSelector()}\").select2({ From 844467f582aec715b574772a2eb3c3493c6e1fc2 Mon Sep 17 00:00:00 2001 From: z-song Date: Wed, 8 Nov 2017 09:48:24 +0800 Subject: [PATCH 0013/1424] bug fix --- src/Form/EmbeddedForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Form/EmbeddedForm.php b/src/Form/EmbeddedForm.php index 8998badd05..a12429e1f9 100644 --- a/src/Form/EmbeddedForm.php +++ b/src/Form/EmbeddedForm.php @@ -217,7 +217,7 @@ protected function formatField(Field $field) { $jsonKey = $field->column(); - $elementName = $elementClass = $errorKey = ''; + $elementName = $elementClass = $errorKey = []; if (is_array($jsonKey)) { foreach ($jsonKey as $index => $name) { From c2b2672403d261db11d90bc5cd6b403f1a713bfe Mon Sep 17 00:00:00 2001 From: z-song Date: Wed, 8 Nov 2017 09:51:08 +0800 Subject: [PATCH 0014/1424] bug fix --- src/Form/Field.php | 2 +- src/Form/NestedForm.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Form/Field.php b/src/Form/Field.php index 55550b7bbf..17bb2da48c 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -736,7 +736,7 @@ public function getViewElementClasses() /** * Set form element class. * - * @param string $class + * @param string|array $class * * @return $this */ diff --git a/src/Form/NestedForm.php b/src/Form/NestedForm.php index 4a3a565713..c14e94519b 100644 --- a/src/Form/NestedForm.php +++ b/src/Form/NestedForm.php @@ -337,7 +337,7 @@ protected function formatField(Field $field) { $column = $field->column(); - $elementName = $elementClass = $errorKey = ''; + $elementName = $elementClass = $errorKey = []; $key = $this->key ?: 'new_'.static::DEFAULT_KEY_NAME; From 56a910ddca21813d25f24792e45c41e70b8ef0c5 Mon Sep 17 00:00:00 2001 From: tomotaka Date: Wed, 15 Nov 2017 16:01:36 +0900 Subject: [PATCH 0015/1424] Fix a typo --- docs/en/model-grid.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/model-grid.md b/docs/en/model-grid.md index 15690ea360..c7645a7a3e 100644 --- a/docs/en/model-grid.md +++ b/docs/en/model-grid.md @@ -180,7 +180,7 @@ $grid->filter(function($filter){ $filter->like('name', 'name'); // sql: ... WHERE `user.email` = $email; - $filter->equal('emial', 'Email'); + $filter->equal('email', 'Email'); // sql: ... WHERE `user.created_at` BETWEEN $start AND $end; $filter->between('created_at', 'Created Time')->datetime(); From 487d3ddfbeb05c4749cd1315285b540a446022c7 Mon Sep 17 00:00:00 2001 From: Song Date: Wed, 15 Nov 2017 04:15:56 -0600 Subject: [PATCH 0016/1424] Update README.md[skip ci] --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a6d02671e..4e7d273526 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,12 @@ Screenshots ![laravel-admin](https://cloud.githubusercontent.com/assets/1479100/19625297/3b3deb64-9947-11e6-807c-cffa999004be.jpg) +Requirements +------------ + - PHP >= 7.0.0 + - Laravel >= 5.5.0 + - Fileinfo PHP Extension + Installation ------------ @@ -68,9 +74,9 @@ php artisan admin:install Open `http://localhost/admin/` in browser,use username `admin` and password `admin` to login. -Default Settings +Configurations ------------ -The file in `config/admin.php` contains an array of settings, you can find the default settings in there. +The file `config/admin.php` contains an array of configurations, you can find the default configurations in there. Other ------------ From 418f001a8c55ada0d49fa669e228ee2ce312b4b4 Mon Sep 17 00:00:00 2001 From: Mykola Nicholas Date: Thu, 16 Nov 2017 00:27:24 +0300 Subject: [PATCH 0017/1424] typo --- tests/config/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config/admin.php b/tests/config/admin.php index f178e976a0..b155b940a5 100644 --- a/tests/config/admin.php +++ b/tests/config/admin.php @@ -18,7 +18,7 @@ 'logo-mini' => 'La', /* - * Route configration. + * Route configuration. */ 'route' => [ From 470530e26028021294c58fde806ad556456dc2ad Mon Sep 17 00:00:00 2001 From: Mykola Nicholas Date: Thu, 16 Nov 2017 00:28:09 +0300 Subject: [PATCH 0018/1424] typo --- config/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/admin.php b/config/admin.php index f178e976a0..b155b940a5 100644 --- a/config/admin.php +++ b/config/admin.php @@ -18,7 +18,7 @@ 'logo-mini' => 'La', /* - * Route configration. + * Route configuration. */ 'route' => [ From ab5fbb2621bb8e696fad2d1560240de27ffceb61 Mon Sep 17 00:00:00 2001 From: z-song Date: Thu, 16 Nov 2017 10:13:01 +0800 Subject: [PATCH 0019/1424] fix issue of select2 search field in modal. --- resources/views/filter/modal.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/filter/modal.blade.php b/resources/views/filter/modal.blade.php index 71440e9cbd..95c32fe288 100644 --- a/resources/views/filter/modal.blade.php +++ b/resources/views/filter/modal.blade.php @@ -3,7 +3,7 @@   {{ trans('admin.reset') }} - From 3b51d4544ed3b8e9d5d2bc61c8acedadf8659b17 Mon Sep 17 00:00:00 2001 From: z-song Date: Mon, 20 Apr 2020 11:03:13 +0800 Subject: [PATCH 1143/1424] [feat]multiple file/image in action form --- .../views/actions/form/muitplefile.blade.php | 5 +++ src/Actions/Action.php | 24 +++++++------ src/Actions/Interactor/Form.php | 35 +++++++++++++++++-- src/Actions/Interactor/Interactor.php | 3 +- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 resources/views/actions/form/muitplefile.blade.php diff --git a/resources/views/actions/form/muitplefile.blade.php b/resources/views/actions/form/muitplefile.blade.php new file mode 100644 index 0000000000..8ed67df936 --- /dev/null +++ b/resources/views/actions/form/muitplefile.blade.php @@ -0,0 +1,5 @@ +
+ + + @include('admin::actions.form.help-block') +
diff --git a/src/Actions/Action.php b/src/Actions/Action.php index e910273860..a1051d22bd 100644 --- a/src/Actions/Action.php +++ b/src/Actions/Action.php @@ -28,6 +28,8 @@ * @method Field\Radio radio($column, $label = '') * @method Field\File file($column, $label = '') * @method Field\Image image($column, $label = '') + * @method Field\MultipleFile multipleFile($column, $label = '') + * @method Field\MultipleImage multipleImage($column, $label = '') * @method Field\Date date($column, $label = '') * @method Field\Datetime datetime($column, $label = '') * @method Field\Time time($column, $label = '') @@ -300,12 +302,12 @@ protected function buildActionPromise() { return << + + + diff --git a/resources/views/form/filepicker.blade.php b/resources/views/form/filepicker.blade.php index bbc03cfe67..c4429a1fd4 100644 --- a/resources/views/form/filepicker.blade.php +++ b/resources/views/form/filepicker.blade.php @@ -6,16 +6,16 @@ @include('admin::form.error') -
+
@foreach($preview as $item) -
+
{!! $item['content'] !!}
-
{!! $item['caption'] !!}
+{{--
{!! $item['caption'] !!}
--}}
- - + ` +
@endforeach diff --git a/src/Form/Field/HasValuePicker.php b/src/Form/Field/HasValuePicker.php index 48d6aec398..a2d0861f17 100644 --- a/src/Form/Field/HasValuePicker.php +++ b/src/Form/Field/HasValuePicker.php @@ -34,7 +34,7 @@ public function pick($picker, $column = '') * @param string $column * @param string $delimiter */ - public function pickMultiple($picker, $column = '', $delimiter = ',') + public function pickMultiple($picker, $column = '', $delimiter = ';') { $this->picker = new ValuePicker($picker, $column, true, $delimiter); diff --git a/src/Form/Field/ValuePicker.php b/src/Form/Field/ValuePicker.php index 359b930d62..2d8290ad29 100644 --- a/src/Form/Field/ValuePicker.php +++ b/src/Form/Field/ValuePicker.php @@ -67,208 +67,6 @@ protected function getLoadUrl() return route('admin.handle-selectable', compact('selectable', 'args')); } - protected function addStyle() - { - Admin::style(<< diff --git a/resources/views/form/filepicker.blade.php b/resources/views/form/filepicker.blade.php index c4429a1fd4..48839ca210 100644 --- a/resources/views/form/filepicker.blade.php +++ b/resources/views/form/filepicker.blade.php @@ -1,39 +1,79 @@ -
+ +
- + -
+
- @include('admin::form.error') + @include('admin::form.error') -
- @foreach($preview as $item) -
-
- {!! $item['content'] !!} -
-{{--
{!! $item['caption'] !!}
--}} -
- ` - +
+ @foreach($preview as $item) +
+
+ @if($item['is_file']) + + @else + + @endif +
+
{{ basename($item['url']) }}
+
+ @endforeach
- @endforeach -
- -
- - - @isset($btn) +
+ {!! $btn !!} - @endisset - -
+
- @include('admin::form.help-block') + @include('admin::form.help-block') +
-
+ + + diff --git a/resources/views/grid/image.blade.php b/resources/views/grid/image.blade.php index ae68374d23..2a7e6f20ed 100644 --- a/resources/views/grid/image.blade.php +++ b/resources/views/grid/image.blade.php @@ -1,45 +1,17 @@
- @if(isset($title)) -
-

{{ $title }}

-
- @endif - -
-
- {!! $grid->renderExportButton() !!} - {!! $grid->renderCreateButton() !!} -
- - {!! $grid->renderHeaderTools() !!} - -
+
{!! $grid->renderFilter() !!}
-
@@ -48,4 +20,32 @@ {!! $grid->paginator() !!}
-
\ No newline at end of file +
+ + diff --git a/src/Form/Field.php b/src/Form/Field.php index 5e1fe86aff..b5b33997cc 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -1509,6 +1509,9 @@ public function render() return view($this->getView(), $this->variables()); } + /** + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string + */ protected function fieldRender() { return self::render(); diff --git a/src/Form/Field/HasValuePicker.php b/src/Form/Field/HasValuePicker.php index a2d0861f17..fce2a29914 100644 --- a/src/Form/Field/HasValuePicker.php +++ b/src/Form/Field/HasValuePicker.php @@ -85,7 +85,7 @@ protected function renderFilePicker() 'btn' => $this->btn ]); - return parent::render(); + return Admin::component('admin::form.filepicker', $this->variables()); } /** diff --git a/src/Form/Field/ValuePicker.php b/src/Form/Field/ValuePicker.php index 2d8290ad29..fbc4ec75c8 100644 --- a/src/Form/Field/ValuePicker.php +++ b/src/Form/Field/ValuePicker.php @@ -95,6 +95,8 @@ public function mount(Field $field) 'separator' => $this->separator, 'multiple' => $this->multiple, 'is_file' => $this->field instanceof File, + 'is_image' => $this->field instanceof Image, + 'url_tpl' => $this->field instanceof File ? $this->field->objectUrl('__URL__') : '', ]); } @@ -110,18 +112,12 @@ public function preview($field) $value = explode($this->separator, $value); } - $previews = []; - - foreach (Arr::wrap($value) as $item) { - - $content = $field == File::class ? '' : ""; - - $previews[] = [ + return collect(Arr::wrap($value))->map(function ($item) use ($field) { + return [ + 'url' => $this->field->objectUrl($item), 'value' => $item, - 'content' => $content, + 'is_file' => $field == File::class, ]; - } - - return $previews; + }); } } diff --git a/src/Grid/Selectable.php b/src/Grid/Selectable.php index 9bf276d6f3..0a73ec111b 100644 --- a/src/Grid/Selectable.php +++ b/src/Grid/Selectable.php @@ -38,6 +38,11 @@ abstract class Selectable */ protected $perPage = 10; + /** + * @var bool + */ + protected $imageLayout = false; + /** * Selectable constructor. * @param $key @@ -56,6 +61,11 @@ public function __construct($multiple = false, $key = '') */ abstract public function make(); + protected function imageLayout() + { + $this->imageLayout = true; + } + /** * @param bool $multiple * @@ -65,25 +75,34 @@ public function render() { $this->make(); - $this->appendRemoveBtn(false); + if ($this->imageLayout) { + $this->setView('admin::grid.image', ['key' => $this->key]); + } else { + $this->appendRemoveBtn(true); + } - $this->paginate($this->perPage) - ->expandFilter() - ->disableExport() - ->disableActions() - ->disableBatchActions() - ->disableCreateButton() - ->disableColumnSelector() - ->disablePerPageSelector(); + $this->paginate($this->perPage)->expandFilter()->disableFeatures(); $displayer = $this->multiple ? Checkbox::class : Radio::class; - $this->prependColumn('__modal_selector__', ' ') - ->displayUsing($displayer, [$this->key]); + $this->prependColumn('__modal_selector__', ' ')->displayUsing($displayer, [$this->key]); return $this->grid->render(); } + /** + * @return $this + */ + protected function disableFeatures() + { + return $this->disableExport() + ->disableActions() + ->disableBatchActions() + ->disableCreateButton() + ->disableColumnSelector() + ->disablePerPageSelector(); + } + public function renderFormGrid($values) { $this->make(); @@ -92,13 +111,7 @@ public function renderFormGrid($values) $this->model()->whereKey(Arr::wrap($values)); - $this->disableFilter() - ->disableExport() - ->disableActions() - ->disableBatchActions() - ->disableCreateButton() - ->disableColumnSelector() - ->disablePerPageSelector(); + $this->disableFilter()->disableFeatures(); if (!$this->multiple) { $this->disablePagination(); diff --git a/src/Traits/HasAssets.php b/src/Traits/HasAssets.php index 77ada33b35..19615a323c 100644 --- a/src/Traits/HasAssets.php +++ b/src/Traits/HasAssets.php @@ -337,18 +337,30 @@ public static function component($component, $data = []) static::script(';(function () {' . $script->nodeValue . '})();'); } - $htmls = ''; + if ($element = $dom->getElementsByTagName('template')[0]) { - if (!$element = $dom->getElementsByTagName('template')[0]) { - return; - } + $html = ''; + + foreach ($element->childNodes as $child) { + $html .= $element->ownerDocument->saveHTML($child); + } - foreach ($element->childNodes as $child) { - $htmls .= $element->ownerDocument->saveHTML($child); + if ($html) { + static::html($html); + } } - if ($htmls) { - static::html($htmls); + if ($element = $dom->getElementsByTagName('render')[0]) { + + $render = ''; + + foreach ($element->childNodes as $child) { + $render .= $element->ownerDocument->saveHTML($child); + } + + if ($render) { + return $render; + } } } } From 71797fe599d721d5e8d822d30291d1a8f676da8e Mon Sep 17 00:00:00 2001 From: z-song Date: Fri, 12 Jun 2020 12:33:32 +0800 Subject: [PATCH 1209/1424] wip --- src/Form/Field.php | 2 +- src/Form/Field/HasValuePicker.php | 53 ++++++++++++------------------- src/Form/Field/PlainInput.php | 13 ++++++-- src/Form/Field/Text.php | 14 ++++---- src/Form/Field/Textarea.php | 6 ++-- src/Form/Field/ValuePicker.php | 51 ++++++++++++++++++----------- 6 files changed, 74 insertions(+), 65 deletions(-) diff --git a/src/Form/Field.php b/src/Form/Field.php index b5b33997cc..6b7fd9d4a0 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -1344,7 +1344,7 @@ public function resetElementClassName(string $className, string $resetClassName) * * @return $this */ - protected function addVariables(array $variables = []): self + public function addVariables(array $variables = []): self { $this->variables = array_merge($this->variables, $variables); diff --git a/src/Form/Field/HasValuePicker.php b/src/Form/Field/HasValuePicker.php index fce2a29914..cf5f7aa57d 100644 --- a/src/Form/Field/HasValuePicker.php +++ b/src/Form/Field/HasValuePicker.php @@ -3,8 +3,12 @@ namespace Encore\Admin\Form\Field; use Encore\Admin\Admin; +use Encore\Admin\Form\Field; use Illuminate\Support\Arr; +/** + * @mixin Field + */ trait HasValuePicker { /** @@ -12,11 +16,6 @@ trait HasValuePicker */ protected $picker; - /** - * @var string - */ - protected $btn = ''; - /** * @param string $picker * @param string $column @@ -32,24 +31,24 @@ public function pick($picker, $column = '') /** * @param string $picker * @param string $column - * @param string $delimiter + * @param string $separator */ - public function pickMultiple($picker, $column = '', $delimiter = ';') + public function pickMany($picker, $column = '', $separator = ';') { - $this->picker = new ValuePicker($picker, $column, true, $delimiter); + $this->picker = new ValuePicker($picker, $column, true, $separator); return $this; } /** - * @return void + * @param \Closure|null $callback + * @return $this */ - protected function mountPicker() + protected function mountPicker(\Closure $callback = null) { - if ($this->picker) { - $this->picker->mount($this); - $this->addVariables(['btn' => $this->btn]); - } + $this->picker && $this->picker->mount($this, $callback); + + return $this; } /** @@ -69,30 +68,18 @@ protected function getRules() */ protected function renderFilePicker() { - $this->view = 'admin::form.filepicker'; - - $this->picker->mount($this); - - $this->attribute('type', 'text') + $this->mountPicker() + ->setView('admin::form.filepicker') + ->attribute('type', 'text') ->attribute('id', $this->id) ->attribute('name', $this->elementName ?: $this->formatName($this->column)) ->attribute('value', old($this->elementName ?: $this->column, $this->value())) ->attribute('class', 'form-control '.$this->getElementClassString()) - ->attribute('placeholder', $this->getPlaceholder()); - - $this->addVariables([ - 'preview' => $this->picker->preview(get_called_class()), - 'btn' => $this->btn - ]); + ->attribute('placeholder', $this->getPlaceholder()) + ->addVariables([ + 'preview' => $this->picker->getPreview(get_called_class()), + ]); return Admin::component('admin::form.filepicker', $this->variables()); } - - /** - * @param string $wrap - */ - public function addPickBtn($btn) - { - $this->btn = $btn; - } } diff --git a/src/Form/Field/PlainInput.php b/src/Form/Field/PlainInput.php index 6f57c438cd..165ff10f86 100644 --- a/src/Form/Field/PlainInput.php +++ b/src/Form/Field/PlainInput.php @@ -15,7 +15,8 @@ trait PlainInput protected $append; /** - * @param $string + * @param mixed $string + * * @return $this */ public function prepend($string) @@ -28,7 +29,7 @@ public function prepend($string) } /** - * @param $string + * @param mixed $string * @return $this */ public function append($string) @@ -40,6 +41,9 @@ public function append($string) return $this; } + /** + * @return void + */ protected function initPlainInput() { if (empty($this->view)) { @@ -47,6 +51,11 @@ protected function initPlainInput() } } + /** + * @param string $attribute + * @param string $value + * @return $this + */ protected function defaultAttribute($attribute, $value) { if (!array_key_exists($attribute, $this->attributes)) { diff --git a/src/Form/Field/Text.php b/src/Form/Field/Text.php index cd2ca09979..3de95eb4e1 100644 --- a/src/Form/Field/Text.php +++ b/src/Form/Field/Text.php @@ -49,14 +49,12 @@ public function render() ->defaultAttribute('name', $this->elementName ?: $this->formatName($this->column)) ->defaultAttribute('value', old($this->elementName ?: $this->column, $this->value())) ->defaultAttribute('class', 'form-control '.$this->getElementClassString()) - ->defaultAttribute('placeholder', $this->getPlaceholder()); - - $this->mountPicker(); - - $this->addVariables([ - 'prepend' => $this->prepend, - 'append' => $this->append, - ]); + ->defaultAttribute('placeholder', $this->getPlaceholder()) + ->mountPicker() + ->addVariables([ + 'prepend' => $this->prepend, + 'append' => $this->append, + ]); return parent::render(); } diff --git a/src/Form/Field/Textarea.php b/src/Form/Field/Textarea.php index 41d52b5c3d..f65da8eec7 100644 --- a/src/Form/Field/Textarea.php +++ b/src/Form/Field/Textarea.php @@ -48,7 +48,9 @@ public function render() $this->value = json_encode($this->value, JSON_PRETTY_PRINT); } - $this->mountPicker($this); + $this->mountPicker(function ($btn) { + $this->addPickBtn($btn); + }); return parent::render()->with([ 'append' => $this->append, @@ -59,7 +61,7 @@ public function render() /** * @param string $wrap */ - public function addPickBtn($btn) + protected function addPickBtn($btn) { $style = << +@endif \ No newline at end of file diff --git a/resources/views/form/filepicker.blade.php b/resources/views/form/filepicker.blade.php index 48839ca210..1accfe99ef 100644 --- a/resources/views/form/filepicker.blade.php +++ b/resources/views/form/filepicker.blade.php @@ -1,47 +1,45 @@ - -
+
- + -
+
- @include('admin::form.error') + @include('admin::form.error') -
- @foreach($preview as $item) -
-
- @if($item['is_file']) - - @else - - @endif -
-
{{ basename($item['url']) }}
- +
+ @foreach($preview as $item) +
+
+ @if($item['is_file']) + + @else + + @endif +
+
{{ basename($item['url']) }}
+ - @endforeach
+ @endforeach +
-
- - - {!! $btn !!} - -
+
+ + + {!! $btn !!} + +
- @include('admin::form.help-block') + @include('admin::form.help-block') -
- +