### Execute SleepingOwl Admin Artisan Commands Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/installation.md This section covers the essential Artisan commands needed to finalize the SleepingOwl Admin installation, including the main setup command and publishing necessary assets for the admin interface. ```bash $ php artisan sleepingowl:install ``` ```bash $ php artisan vendor:publish --tag=assets --force ``` -------------------------------- ### Run SleepingOwl Admin Installation Artisan Command Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md Execute this Artisan command to perform the initial setup for SleepingOwl Admin. It publishes configuration files, assets, and creates essential directories and files like `navigation.php` and `bootstrap.php` for the admin panel. ```bash $ php artisan sleepingowl:install ``` -------------------------------- ### Update Composer Dependencies Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md After modifying `composer.json` or to resolve new dependencies, execute this command. Composer will then download and install the specified packages, ensuring your project's dependencies are up-to-date. ```bash $ composer update ``` -------------------------------- ### Install SleepingOwl Admin via Composer Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/installation.md This section details the Composer commands and `composer.json` modifications required to add the SleepingOwl Admin package to your Laravel project. It includes requiring the package and updating dependencies. ```bash $ composer require laravelrus/sleepingowl //or branch $ composer require laravelrus/sleepingowl:dev-development ``` ```json { ... "require": { ... "laravelrus/sleepingowl": "dev-development" } } ``` ```bash $ composer update ``` -------------------------------- ### Install SleepingOwl Admin with Composer Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md This command installs the SleepingOwl Admin package as a dependency in your Laravel project using Composer. It supports both the stable release and specific development branches for testing or early access. ```bash $ composer require laravelrus/sleepingowl //or branch $ composer require laravelrus/sleepingowl:dev-development ``` -------------------------------- ### Register SleepingOwl Admin Service Provider Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/installation.md After installing the package, the SleepingOwl Admin Service Provider must be registered in your Laravel application's `config/app.php` file to enable its functionalities. ```php 'providers' => [ ... /** * SleepingOwl Service Provider */ SleepingOwl\Admin\Providers\SleepingOwlServiceProvider::class, /** * Application Service Providers... */ App\Providers\AppServiceProvider::class, ... ] ``` -------------------------------- ### Publish SleepingOwl Admin Assets via Artisan Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md This Artisan command specifically publishes the SleepingOwl Admin assets to your public directory. It's often used to ensure all necessary frontend files are available or to force an update of published assets. ```bash $ php artisan vendor:publish --tag=assets --force ``` -------------------------------- ### Basic Table Display Configuration Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Demonstrates the basic setup for displaying data in a table using `AdminDisplay::table()` within the `onDisplay` method of a model. This is the starting point for defining how data will be presented. ```php $model->onDisplay(function () { $display = AdminDisplay::table(); ... return $display; }); ``` -------------------------------- ### Register SleepingOwl Admin Service Provider in Laravel Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md For Laravel versions prior to 5.5 or if automatic discovery is disabled, manually register the `SleepingOwlServiceProvider` in your `config/app.php` file. This step ensures the package's services and functionalities are loaded and available within your Laravel application. ```php 'providers' => [ ... /** * SleepingOwl Service Provider */ SleepingOwl\Admin\Providers\SleepingOwlServiceProvider::class, /** * Application Service Providers... */ App\Providers\AppServiceProvider::class, ... ] ``` -------------------------------- ### Manually Add SleepingOwl Admin to composer.json Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/installation.md Alternatively, you can manually declare the SleepingOwl Admin package in your `composer.json` file under the `require` section. This method is useful for specifying exact versions or development branches before running `composer update`. ```json { ... "require": { ... "laravelrus/sleepingowl": "dev-development" } } ``` -------------------------------- ### Install Intervention/Image and Register Service Provider Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Instructions for installing the `intervention/image` package via Composer and registering its Laravel service provider (`Intervention\Image\ImageServiceProviderLaravel5::class`) in `config/app.php` to enable image processing features. ```bash composer require intervention/image ``` -------------------------------- ### Illustrative Example of Applying Intervention/Image Filters Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Shows how `intervention/image` filters are internally applied using `call_user_func_array` with an image instance and filter arguments, mirroring the behavior of `setUploadSettings`. This clarifies the mechanism by which filter settings are processed. ```php $image = \Intervention\Image\Facades\Image::make($file) call_user_func_array([$image, 'resize'], [1280, null, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }]) ``` -------------------------------- ### Generate Laravel Authentication Scaffolding Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/authentication.md Executes the Laravel Artisan command to generate basic authentication scaffolding, including views, routes, and controllers, as part of the quickstart guide for setting up user authentication. ```bash $ php artisan make:auth ``` -------------------------------- ### Setting Table Columns with AdminColumn Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Illustrates how to define columns for a table display using `setColumns()` or by pushing columns to `getColumns()`. It shows examples of `AdminColumn::link`, `AdminColumn::datetime`, and `AdminColumn::text` for various data types and formatting. ```php $display->setColumns([ ... AdminColumn::link('title')->setLabel('Title'), AdminColumn::datetime('created_at')->setLabel('Created')->setFormat('d.m.Y'), ... ]); // or $display->getColumns()->push( AdminColumn::text('title') ); ``` -------------------------------- ### Configuring Actions for Table Rows Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Shows how to define actions that can be performed on table rows, typically using `AdminColumn::action`. It includes an example of an 'export' action with an icon and a route, and demonstrates how to customize the placement and HTML attributes of the action buttons. ```php $table = AdminDisplay::table() ->setActions([ AdminColumn::action('export', 'Export')->setIcon('fa fa-share')->setAction(route('news.export')), ]) ->setColumns([ AdminColumn::checkbox(), ... ]); // Изменить разсположение положения кнопок на странице $table->getActions() ->setPlacement('panel.buttons') ->setHtmlAttribute('class', 'pull-right'); ``` -------------------------------- ### Enable and Customize DataTable Row Highlighting Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/configuration.md This example shows how to enable global row highlighting on mouseover for DataTables via configuration and how to apply specific CSS classes to a DataTable instance to customize its appearance and ensure the highlighting feature is active. ```php // Configuration setting 'datatables_highlight' => true; ``` ```php // Example usage in a section $display = AdminDisplay::datatablesAsync() ->setHtmlAttribute('class', 'table-primary table-striped table-hover lightcolumn'); ``` -------------------------------- ### Applying Column Filters to Table Display Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Shows how to add filters to table columns using `setColumnFilters()` or by pushing filters to `getColumnFilters()`. This example uses `AdminColumnFilter::text()` to create a text input filter with a placeholder. ```php $display->setColumnFilters([ ... AdminColumnFilter::text()->setPlaceholder('Full Name'), ... ]); // or $display->getColumnFilters()->push( AdminColumnFilter::text()->setPlaceholder('Full Name') ); ``` -------------------------------- ### Configure Excluded Environment Editor Keys Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/configuration.md This configuration array specifies keys that should be excluded from the environment editor. Wildcards (`*`) can be used to match multiple keys. For example, `APP_KEY` and all `DB_*` keys are excluded by default. ```php 'env_editor_excluded_keys' => [ 'APP_KEY', 'DB_*', ], ``` -------------------------------- ### Advanced File Upload Configuration and Attribute Setter Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/form-element.md A comprehensive example demonstrating multiple image casts, detailed `getUploadSettings` for different image sizes (e.g., `image`, `thumb`), and a custom `setUploadImageAttribute` method for handling file assignment. ```php /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'image' => 'image', 'thumb' => 'image', ]; /** * @return array */ public function getUploadSettings() { return [ 'image' => [ 'orientate' => [], 'resize' => [1280, null, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }] ], 'thumb' => [ 'orientate' => [], 'fit' => [200, 300, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }] ] ]; } /** * @param \Illuminate\Http\UploadedFile $file */ public function setUploadImageAttribute(\Illuminate\Http\UploadedFile $file = null) { if (is_null($file)) { return; } foreach ($this->getUploadFields() as $field) { $this->{$field.'_file'} = $file; } } ``` -------------------------------- ### Define Image Processing Rules with getUploadSettings Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Shows how to implement the `getUploadSettings()` method in your model to specify image manipulation rules using the Intervention Image library. This example demonstrates 'fit' and 'crop' operations for an 'image' field, allowing custom resizing and cropping configurations. ```php /** * @return array */ public function getUploadSettings() { return [ 'image' => [ // Field key // Function name to apply to the image http://image.intervention.io/api/fit and parameters passed to it 'fit' => [300, 300, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }], 'crop' => [300, 300], // http://image.intervention.io/api/crop ... ], 'image_small' => [ ... ] ]; } ``` -------------------------------- ### Example Usage of Dependent Select Fields Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Demonstrates how to implement a dependent select field where the 'City' selection is dynamically filtered based on the chosen 'Country'. It utilizes `setDataDepends` and `setLoadOptionsQueryPreparer` for this functionality. ```php AdminFormElement::select('country_id', 'Country') ->setModelForOptions(Country::class, 'title'), AdminFormElement::dependentselect('city_id', 'City') ->setModelForOptions(\App\Model\City::class, 'title') ->setDataDepends(['country_id']) ->setLoadOptionsQueryPreparer(function($item, $query) { return $query->where('country_id', $item->getDependValue('country_id')); }) ``` -------------------------------- ### Example Usage of `AdminFormElement::manyToMany` with Tabs Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md These examples illustrate how to effectively use `AdminFormElement::manyToMany` in conjunction with tabs for managing `belongsToMany` and `morphToMany` relationships. It shows how to define custom pivot fields and use `setRelatedElementDisplayName` with both string and closure callbacks. ```php $manyToMany = AdminForm::form()->addElement( new FormElements( [ AdminFormElement::manyToMany('users', [ AdminFormElement::text('name', 'Название'), AdminFormElement::select('color_id', 'Цвет', Colot::class)->setDisplay('name_color'), AdminFormElement::images('images', 'Фото'), AdminFormElement::checkbox('is_done', 'Готово?'), AdminFormElement::datetime('date', 'Дата оплаты'), ])->setRelatedElementDisplayName(function ($model){ return $model->full_name; }) ]) ); ``` ```php $morphToMany = AdminForm::form()->addElement( new FormElements( [ AdminFormElement::manyToMany('features', [ AdminFormElement::text('equip', 'Экипирован'), AdminFormElement::datetime('date', 'Время'), ])->setRelatedElementDisplayName('title') ]) ); ``` ```php $tabs = AdminDisplay::tabbed([]); $tabs->appendTab($manyToMany, 'Много ко многим'); $tabs->appendTab($morphToMany, 'Один ко многим через модель'); ``` -------------------------------- ### AdminFormElement Select setUsageKey Example Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Demonstrates how to use the `setUsageKey` method on an `AdminFormElement::select` field to specify a custom key for saving the selected value, overriding the default behavior. ```PHP AdminFormElement::select('role_id', 'Роль', Role::class) ->setUsageKey('new_id'), ``` -------------------------------- ### Implement Dropdown Select Filters in SleepingOwl Admin (PHP) Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/columnfilters.md Illustrates how to create select (dropdown) filters in SleepingOwl Admin. Examples include defining options via a static array or dynamically from a model, with custom display logic and query preparation. It also shows how to set width, column name, and placeholder. ```php //массивом AdminColumnFilter::select() ->setOptions([ 'sender' => 'Отправитель', 'recipient' => 'Получатель', ]) ->setWidth('15rem') ->setColumnName('payer_type') ->setPlaceholder('Все'), //моделью AdminColumnFilter::select() ->setModelForOptions(Sender::class) ->setDisplay(function($filter){ return $filter->id . ' - ' . $filter->description; }) ->setWidth('15rem') ->setFetchColumns('description') //id и так выбирается ->setColumnName('sender_id') ->setLoadOptionsQueryPreparer(function($element, $query) { //любая своя логика либо скоуп return $query->active(); }) ->setPlaceholder('Все отправители'), //другое AdminColumnFilter::select() ->setOptions([ 'http://' => 'Внешние изображения', 'https://' => 'Внешние изображения 2', 'http' => 'Внешние все', ]) ->setWidth('20rem') ->setOperator(\SleepingOwl\Admin\Contracts\Display\Extension\FilterInterface::BEGINS_WITH) ->setColumnName('image') ->setPlaceholder('Все'), ``` -------------------------------- ### SleepingOwl Admin Form Element Behavioral API with Examples Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Methods to control the behavior of SleepingOwl Admin form elements, such as read-only status, value skipping during saving, visibility conditions, and value mutation before saving to the model. Includes PHP examples for dynamic behavior. ```APIDOC setReadonly(bool|Closure $status): static - Sets the read-only attribute for the field. - If the field is read-only, it will be ignored during validation and saving. - Parameters: - $status: A boolean value or a Closure that returns a boolean. The Closure receives the model as an argument. - Returns: The current form element instance for chaining. setValueSkipped(bool|Closure $valueSkipped): static - Sets whether the field's value should be skipped when saving to the model. - If the value is skipped, validation rules will still apply, but the value will not be set on the model. - Parameters: - $valueSkipped: A boolean value or a Closure that returns a boolean. - Returns: The current form element instance for chaining. setVisibilityCondition(Closure $condition): static - Sets a condition for the field's visibility. - If the field is hidden, it will be ignored during validation and saving. - Parameters: - $condition: A Closure that returns a boolean, determining visibility. The Closure receives the model as an argument. - Returns: The current form element instance for chaining. mutateValue(Closure $mutator): static - Modifies the field's value before it is passed to the model. - Parameters: - $mutator: A Closure that receives the field's value and returns the mutated value. - Returns: The current form element instance for chaining. ``` ```PHP $field->setReadOnly(true); $field->setReadOnly(function($model) { return $model->author_id != auth()->id(); }); $field->setReadOnly(function($model) { return !auth()->check(); }); AdminFormElement::text('password', 'Password')->required(); AdminFormElement::text('password_confirmation', 'Password confirmation') ->setValueSkipped(true) ->required() ->addValidationRule('same:password', 'Passwords must match!'); $field->setVisibilityCondition(function($model) { return auth()->user()->isAdmin(); }); $field->setVisibilityCondition(function($model) { return $model->author_id == auth()->id(); }); $field->mutateValue(function($value) { return bcrypt($value); }); ``` -------------------------------- ### Range Filter Configuration Methods (APIDOC) Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/columnfilters.md Documents the methods for configuring range-based filters in SleepingOwl Admin. This includes setting the start and end fields of the range and an option to align the input fields inline for better presentation. ```APIDOC Range Filter: - setInline(true): - Description: Aligns range input fields in a single line for improved layout. - Availability: Developer version or v7.20+ - setFrom(ColumnFilterInterface $from): - Description: Specifies the starting field for the range filter. - Parameters: - $from: An instance of ColumnFilterInterface representing the start column. - Returns: self (for method chaining) - setTo(ColumnFilterInterface $from): - Description: Specifies the ending field for the range filter. - Parameters: - $from: An instance of ColumnFilterInterface representing the end column. - Returns: self (for method chaining) ``` -------------------------------- ### Modifying Display Query with setApply Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Explains how to modify the underlying database query for the display using `setApply()`. It shows examples of applying custom query logic, such as ordering by a specific column, using a single closure, an array of closures, or pushing to `getApply()`. ```php $display->setApply(function ($query) { $query->orderBy('title', 'asc'); }); // or $display->setApply([ ... function ($query) { $query->orderBy('title', 'asc'); }, ... ]); // or $display->getApply()->push(function ($query) { $query->orderBy('title', 'asc'); }); ``` -------------------------------- ### HtmlAttributes Trait API Reference Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/html_attributes.md Comprehensive API documentation for the `HtmlAttributes` trait, detailing methods for setting, modifying, querying, and removing HTML attributes, as well as converting them to a string for rendering. Includes examples for individual and bulk attribute operations. ```APIDOC setHtmlAttribute(string $attribute, string|array $value): void - Purpose: Sets a single HTML attribute or appends values to an existing attribute (e.g., 'class'). - Parameters: - $attribute (string): The name of the HTML attribute (e.g., 'class', 'id'). - $value (string|array): The value(s) to set for the attribute. If an array, values are joined for attributes like 'class'. - Example: $column->setHtmlAttribute('class', 'bg-primary'); $column->setHtmlAttribute('class', 'text-right'); $column->setHtmlAttribute('id', 'row-3'); $column->setHtmlAttribute('data-value', 'test'); setHtmlAttributes(array $attributes): void - Purpose: Sets multiple HTML attributes from an associative array. - Parameters: - $attributes (array): An associative array where keys are attribute names and values are attribute values (string or array). - Example: $column->setHtmlAttributes([ 'class' => ['bg-primary', 'text-right'], 'id' => 'row-3', 'data-value' => 'test' ]); - Result Example: // return test replaceHtmlAttribute(string $attribute, string|array $value): void - Purpose: Replaces the value of an existing HTML attribute. - Parameters: - $attribute (string): The name of the HTML attribute. - $value (string|array): The new value(s) for the attribute. - Example: $column->replaceHtmlAttribute('class', 'new-class'); - Result Example: // return test hasClassProperty(string $className): bool - Purpose: Checks if the 'class' attribute contains a specific class name. - Parameters: - $className (string): The class name to check for. - Returns: (bool) True if the class exists, false otherwise. - Example: $column->setHtmlAttribute('class', 'new-class'); $column->hasClassProperty('new-class'); // return true hasHtmlAttribute(string $attribute): bool - Purpose: Checks for the existence of any HTML attribute. - Parameters: - $attribute (string): The name of the HTML attribute to check. - Returns: (bool) True if the attribute exists, false otherwise. - Example: $column->setHtmlAttribute('data-value', 'test'); $column->hasHtmlAttribute('data-value'); // return true removeHtmlAttribute(string $attribute): void - Purpose: Removes a specific HTML attribute. - Parameters: - $attribute (string): The name of the HTML attribute to remove. - Example: $column->removeHtmlAttribute('data-value'); clearHtmlAttributes(): void - Purpose: Removes all HTML attributes. - Example: $column->clearHtmlAttributes(); htmlAttributesToString(): string - Purpose: Converts all stored HTML attributes into a single string suitable for direct insertion into an HTML tag. - Returns: (string) A string representation of all attributes (e.g., 'class="foo" id="bar"'). - Example: $column->htmlAttributesToString(); - Result Example: // return "class="new-class" id="row-3" data-value="test"" ``` -------------------------------- ### Define One-to-Many Relationship Form Element in SleepingOwl Admin Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md This example demonstrates how to use `AdminFormElement::hasMany` to create a form element that allows managing multiple related entities (e.g., addresses) within a single form. It simplifies the creation of many entities of the same type. ```php AdminFormElement::hasMany('addresses', [ AdminFormElement::text('field_address', 'Название сущности адреса') ]) ``` -------------------------------- ### Set Table Columns Total Row and Query Aggregation in SleepingOwl Admin Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Configures an aggregation row to be displayed at the bottom of a SleepingOwl Admin table, showing total values for specified columns. It also provides an example of how to apply the current display filters to a separate query to calculate aggregated data. ```php $table->setColumnsTotal([ 'Total: ', '', ... ], $table->getColumns()->all()->count() ); $totalQuery = ::query(); $table->getFilters()->initialize(); $table->getFilters()->modifyQuery($totalQuery); ``` -------------------------------- ### System Paths, Providers, and Formatting Configuration Parameters Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/configuration.md This section details configuration parameters related to system paths, authentication providers, template classes, and date/time formatting used throughout the SleepingOwl Admin panel. ```APIDOC auth_provider: string - Auth Provider. Refer to Laravel's Custom User Providers documentation (default: 'users'). bootstrapDirectory: string - The path to the autoload SleepingOwl Admin (default: app_path('Admin')). imagesUploadDirectory: string - Image upload directory. Relative path from public directory (default: 'images/uploads'). filesUploadDirectory: string - File upload directory. Relative path from public directory (default: 'files/uploads'). template: string - Template class. Must implement interface SleepingOwl\Admin\Contracts\TemplateInterface (default: SleepingOwl\Admin\Templates\TemplateDefault::class). datetimeFormat: string - Date and time format for form and display elements (default: 'd.m.Y H:i'). dateFormat: string - Date format for form and display elements (default: 'd.m.Y'). timeFormat: string - Time format for form and display elements (default: 'H:i'). wysiwyg: array - Default settings for Wysiwyg editors. ``` -------------------------------- ### Configure Image Upload Settings with Intervention/Image Filters Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Demonstrates how to use the `setUploadSettings` method to apply `intervention/image` filters like `orientate`, `resize`, and `fit` during image uploads. Filters are defined as an associative array where keys are filter names and values are arrays of arguments for the respective filter function. ```php $field->setUploadSettings([ 'orientate' => [], 'resize' => [1280, null, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }], 'fit' => [200, 300, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }] ]); ``` -------------------------------- ### Disconnecting a WYSIWYG Editor from a Textarea Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/javascript.md This example shows how to deactivate an active WYSIWYG editor from a textarea using `Admin.WYSIWYG.switchOff`. It only requires the textarea's ID to identify which editor instance to disconnect. ```js Admin.WYSIWYG.switchOff('MyTextarea') ``` -------------------------------- ### General UI and Branding Configuration Parameters Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/configuration.md This section details configuration parameters related to the SleepingOwl Admin panel's user interface, branding, and general access settings, including page titles, logos, URL prefixes, and middleware. ```APIDOC title: string - String to display in page title. logo: string - Logo displayed in the upper panel. logo_mini: string - Admin mini logo for small display or minimized sidebar. menu_top: string - Text displayed above the menu (only in @dev-development branch). url_prefix: string - Admin URL prefix (default: 'admin'). domain: boolean - Enable/disable admin on subdomain (default: false). middleware: array - Middleware that restricts the administrative module from unauthorized users (default: ['web', 'auth']). breadcrumbs: boolean - Enable/disable breadcrumbs (default: true). scroll_to_top: boolean - Enable/disable scroll to top page button (default: true). scroll_to_bottom: boolean - Enable/disable scroll to bottom page button (default: true). imageLazyLoad: boolean - Enable/disable lazy loading images in tables and datatables. imageLazyLoadFile: string - The default image to display for unloaded pages. Can be an empty GIF data URI or a path relative to the public folder. aliases: array - Package aliases. ``` -------------------------------- ### Get Table Columns Total Object in SleepingOwl Admin Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Retrieves the ColumnsTotal extension object, which allows further configuration of the aggregated row displayed at the bottom of a SleepingOwl Admin table, such as setting its placement. ```php $display->getColumnsTotal()->setPlacement('table.footer') ``` -------------------------------- ### Admin Module Registration and Execution API Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/javascript.md Manages code modules that execute upon system startup or specific events. This API provides mechanisms to register reusable code blocks with defined priorities and event triggers, and to manually invoke them. ```javascript Admin.Modules.register(key, function() { // your js code here ... }, prioroty, events); // Description: Registers a new module with the system. // Parameters: // key: string - A ``` -------------------------------- ### SleepingOwl Admin Configuration Parameters Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/configuration.md This section details the various configuration options available in the `sleeping_owl.php` file for SleepingOwl Admin. These settings control aspects like application title, logo, URL prefixes, middleware, environment editor behavior, file uploads, date/time formats, and more. ```APIDOC title (string): Sets the title displayed in the administration panel. logo (string): Specifies the path to the main logo image for the admin panel. logo_mini (string, @deprecated in ver. 6+): Specifies the path to the mini logo image for the admin panel. This option is deprecated in version 6 and above. url_prefix (string, default: 'admin'): Defines the URL prefix for the administration panel routes. domain (boolean, default: false): Sets the domain for the administration panel routes. If `false`, it uses the application's default domain. middleware (array, default: ['web', 'auth']): An array of middleware to apply to the administration panel routes. enable_editor (boolean, default: false): Enables or disables the environment editor functionality within the admin panel. env_editor_url (string, default: 'env/editor'): Defines the URL path for the environment editor. env_editor_policy (string|null, default: null): Specifies a policy class to control access to the environment editor. env_editor_excluded_keys (array): An array of environment variable keys to exclude from the editor. Supports wildcards. env_editor_middlewares (array, default: []): An array of middleware to apply specifically to the environment editor routes. auth_provider (string, default: 'users'): Specifies the authentication provider to use for the admin panel. Refer to Laravel's Custom User Providers for more details. bootstrapDirectory (string, default: app_path('Admin')): Defines the directory where SleepingOwl Admin's bootstrap files are located. imagesUploadDirectory (string, default: 'images/uploads'): Sets the default directory for image uploads. filesUploadDirectory (string, default: 'files/uploads'): Sets the default directory for general file uploads. template (string, default: SleepingOwl\Admin\Templates\TemplateDefault::class): Specifies the template class to use for rendering the admin interface. Must implement `SleepingOwl\Admin\Contracts\TemplateInterface`. datetimeFormat (string, default: 'd.m.Y H:i'), dateFormat (string, default: 'd.m.Y'), timeFormat (string, default: 'H:i'): Defines the default date, time, and datetime formats used throughout the admin panel. wysiwyg (mixed): Configures the WYSIWYG editor settings. datatables (array, default: []): An array for configuring DataTables options. dt_autoupdate (boolean, default: false): Enables or disables automatic updates for DataTables. dt_autoupdate_interval (integer, default: 5): Sets the interval in seconds for DataTables automatic updates. dt_autoupdate_class (string, default: ''): Specifies a CSS class to apply to DataTables rows that have been updated. dt_autoupdate_color (string, default: '#dc3545'): Sets the background color for DataTables rows that have been updated. breadcrumbs (boolean, default: true): Enables or disables breadcrumbs navigation in the admin panel. aliases (array): An array for defining custom aliases within the admin panel. ``` -------------------------------- ### Environment Editor Configuration Parameters Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/configuration.md This section outlines configuration parameters for the built-in environment (ENV) file editor, allowing control over its enablement, read-only status, key management, URL slug, and middleware. ```APIDOC enable_editor: boolean - Enabling and adding editing ENV settings (default: false). env_keys_readonly: boolean - Makes the view-only key field (default: false). env_can_delete: boolean - Allows/denies key/value deletion (default: true). env_can_add: boolean - Allows/denies adding a key/value (if env_keys_readonly == false) (default: true). env_editor_url: string - Slug for editing env settings file (default: 'env/editor'). env_editor_policy: string|null - Adding a Policy (default: null). env_editor_excluded_keys: array - An array of keys or key masks to hide in the settings ENV-editor. env_editor_middlewares: array - Adding an middleware for editing settings (default: []). ``` -------------------------------- ### Customize Uploaded File Naming Convention Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/form-element.md Provides an example of overriding the default file naming convention for uploaded files by implementing the `getUploadFilename` method, allowing for custom filenames based on model attributes. ```php /** * @param UploadedFile $file * * @return string */ protected function getUploadFilename(\Illuminate\Http\UploadedFile $file) { return md5($this->id).'.'.$file->getClientOriginalExtension(); } ``` -------------------------------- ### Configure WYSIWYG Editor Field Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/form-element.md Configures a What You See Is What You Get (WYSIWYG) editor field. It allows specifying the editor type, height, and additional parameters, along with options for handling filtered HTML output. ```php AdminFormElement::wysiwyg(string $key, string $label = null, string $editor = null) ``` ```APIDOC $field->setFilteredValueToField(string $field): Sets a field key to store the compiled HTML value (e.g., for markdown). $field->disableFilter(): Disables compiling data to HTML. $field->setEditor(string $editor): Sets the editor name (e.g., 'ckeditor', 'tinymce', 'simplemde'). $field->setHeight(int $height): Sets the height of the editor in pixels. $field->setParameters(array $parameters): Provides additional parameters to the editor, which will be JSON encoded. ``` -------------------------------- ### Publish SleepingOwl Admin Configuration File Source: https://github.com/sleepingowladmin/docs/blob/new/_convert/template/configuration.md This command publishes the `sleeping_owl.php` configuration file to your application's config directory, allowing you to customize various settings for SleepingOwl Admin. It uses the `vendor:publish` Artisan command with the specified service provider and tag. ```bash $ php artisan vendor:publish --provider="SleepingOwl\Admin\Providers\SleepingOwlServiceProvider" --tag="config" ``` -------------------------------- ### Registering and Configuring a Model in SleepingOwl Admin Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/model_configuration.md This snippet demonstrates the fundamental process of registering a model with SleepingOwl Admin. It shows how to define the model's title, configure its display (table columns), and set up the create and edit forms with various input elements. It also illustrates how to add the model to the admin menu with a specific icon. ```php AdminSection::registerModel(Company::class, function (ModelConfiguration $model) { $model->setTitle('Companies'); // Display $model->onDisplay(function () { $display = AdminDisplay::table()->setColumns([ AdminColumn::link('title')->setLabel('Title')->setWidth('400px'), AdminColumn::text('address')->setLabel('Address')->setAttribute('class', 'text-muted'), ]); $display->paginate(15); return $display; }); // Create And Edit $model->onCreateAndEdit(function() { $form = AdminForm::panel()->addBody( AdminFormElement::text('title', 'Title')->required()->unique(), AdminFormElement::textarea('address', 'Address')->setRows(2), AdminFormElement::text('phone', 'Phone') ); return $form; }); }) ->addMenuPage(Company::class, 0) ->setIcon('fa fa-bank'); ``` -------------------------------- ### Admin.Asset Module for Dynamic Asset Loading Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/javascript.md The `Admin.Asset` module facilitates dynamic loading of CSS, JavaScript, and image files. It prevents duplicate loading and returns a Promise for asynchronous operations. ```APIDOC Admin.Asset.css(url: string): Promise - Loads a CSS file. - If a file with the given path is already added to the page, it will be skipped. - Returns a Promise object that resolves when the file is loaded. Admin.Asset.js(url: string): Promise - Loads a JavaScript file. - If a file with the given path is already added to the page, it will be skipped. - Returns a Promise object that resolves when the file is loaded. Admin.Asset.img(url: string): Promise - Loads an image file. - Returns a Promise object that resolves with the image URL when loaded. - Example: Admin.Asset.img('http://sizte.com/logo.png').then(function(url) { $('#images').append(''); }) ``` -------------------------------- ### Configure Image Upload Settings with Intervention Image Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/form-element.md Shows how to implement the `getUploadSettings` method in a model to define image manipulation rules (e.g., `fit`, `crop`) using the Intervention Image library for different image fields. ```php /** * @return array */ public function getUploadSettings() { return [ 'image' => [ // Model key // see http://image.intervention.io/api/fit 'fit' => [300, 300, function ($constraint) { $constraint->upsize(); $constraint->aspectRatio(); }], // see http://image.intervention.io/api/crop 'crop' => [300, 300], ... ], 'image_small' => [ ... ] ]; } ``` -------------------------------- ### Customize Uploaded Filename with getUploadFilename Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Provides an example of overriding the default file naming convention by implementing the `getUploadFilename()` method. This allows you to define a custom filename, such as using an MD5 hash of the model ID combined with the original file extension. ```php /** * @param UploadedFile $file * * @return string */ protected function getUploadFilename(\Illuminate\Http\UploadedFile $file) { return md5($this->id).'.'.$file->getClientOriginalExtension(); } ``` -------------------------------- ### Configure Dependent Select Options Query Preparer Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Sets a callback function to prepare the query for loading options in a dependent select field. This allows dynamic filtering of options based on values from other form fields, ensuring data consistency. ```APIDOC setLoadOptionsQueryPreparer(Closure $callback): static - Sets a callback to prepare the query for loading options in a dependent select field. - Parameters: - $callback: A Closure that receives the element and the query, and should return the modified query. Inside the callback, getDependValue() can be used to retrieve values from related fields. ``` ```php $field->setLoadOptionsQueryPreparer(function($element, $query) { // метод getDependValue используется для получения значения связанного поля // При загрузке формы метод вернет $model->getAttribute($key) // При выполнении ajax запроса $request->input('depdrop_all_params.{$key}') return $query->where('country_id', $element->getDependValue('country_id')); }) ``` -------------------------------- ### Admin Configuration Management API Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/javascript.md Manages application settings stored in the global `window.GlobalConfig` object. This API allows for dynamic access and modification of configuration values, including system states, URLs, and user-specific settings. ```APIDOC Admin.Config.get(key, [default]) - Description: Retrieves a configuration value by its key. - Parameters: - key: string - The configuration key to retrieve. - default: any (optional) - The default value to return if the key is not found. - Returns: any - The configuration value or the default if specified. Admin.Config.set(key, value) - Description: Sets a configuration value for a given key. - Parameters: - key: string - The configuration key to set. - value: any - The value to assign to the key. - Returns: void Admin.Config.has(key) - Description: Checks if a configuration key exists. - Parameters: - key: string - The configuration key to check. - Returns: boolean - True if the key exists, false otherwise. Admin.Config.merge(config) - Description: Merges a new configuration object into the existing application configuration. - Parameters: - config: object - An object containing key-value pairs to merge. - Returns: void Admin.Config.all() - Description: Retrieves all current configuration settings as an object. - Returns: object - An object containing all configuration key-value pairs. // Common configuration keys accessible via Admin.Config.get(): // 'debug': boolean - Application debug state. // 'env': string - Application environment (e.g., 'production', 'development'). // 'locale': string - Current application locale. // 'url': string - Base URL of the application. // 'url_path': string - Relative path of the application (available in @dev-development branch). // 'lang': object - Current localization keys and their values. // 'wysiwyg': object - WYSIWYG editor settings from the configuration file. // 'template': object - Information about the default template. // 'user_id': number - Identifier of the currently active user. // 'datetime_format': string - Current format for date and time display. // 'date_format': string - Current format for date display. // 'state_tabs': boolean - Indicates if tab activity state should be preserved. // 'state_filters': boolean - Indicates if datatables filter values should be preserved. ``` -------------------------------- ### Eager Loading Relationships for Table Display Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Demonstrates how to use the `with()` method to eager load related models (e.g., 'country', 'companies') when displaying data. This optimizes database queries by reducing N+1 problems, especially useful for relationships. ```php $display->with('country', 'companies'); ``` -------------------------------- ### Apply Validation Rules to Upload Fields Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/form-element.md Explains how to add validation rules to file upload fields using `addValidationRule()`. Examples include validating an 'image' field with the 'image' rule and a 'pdf' field with the 'mimes:pdf' rule, leveraging Laravel's validation capabilities. ```php AdminFormElement::upload('image', 'Image')->addValidationRule('image') // or for file AdminFormElement::upload('pdf', 'PDF')->addValidationRule('mimes:pdf'), ``` -------------------------------- ### Applying Eloquent Scopes to Display Query Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md Illustrates how to apply Eloquent query scopes to the data displayed in the table. It demonstrates using `setScopes()` with a single scope name, an array of scope names, or pushing a scope to `getScopes()`. ```php $display->setScopes('last'); //or $display->setScopes(['last', 'trashed']); // or $display->getScopes()->push('last'); ``` -------------------------------- ### Publish SleepingOwl Admin Configuration File Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/configuration.md This Artisan command publishes the default `sleeping_owl.php` configuration file to your application's `config` directory, allowing you to customize the SleepingOwl Admin panel's settings. ```bash $ php artisan vendor:publish --provider="SleepingOwl\Admin\Providers\SleepingOwlServiceProvider" --tag="config" ``` -------------------------------- ### Configure Composer Post-Update Hook for Asset Publishing Source: https://github.com/sleepingowladmin/docs/blob/new/docs/en/update.md This JSON snippet demonstrates how to add an Artisan command to Composer's `post-update-cmd` script within `composer.json`. This configuration ensures that vendor assets are automatically published and forced after every `composer update` operation, streamlining the update process. ```json { "scripts": { "post-update-cmd": [ ... "php artisan vendor:publish --tag=assets --force" ] } } ``` -------------------------------- ### Custom Tree Type Integration for SleepingOwl Admin DisplayTree Source: https://github.com/sleepingowladmin/docs/blob/new/docs/ru/displays.md This section details how to integrate custom tree libraries, such as `gazsp/baum`, with `SleepingOwl\Admin\Display\DisplayTree`. It involves extending `BaumNodeType` and overriding the `getTree` method to correctly retrieve and format the tree structure from the chosen library. This allows for flexible tree data management beyond default implementations, with usage like `AdminDisplay::tree(\Admin\Tree\CustomBaumNodeType::class)->...`. ```php toSortedHierarchy(); } } ```