PHP code example of monstrex / ave

1. Go to this page and download the library: Download monstrex/ave library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

monstrex / ave example snippets




namespace App\Ave\Resources;

use Monstrex\Ave\Admin\BaseResource;
use Monstrex\Ave\Core\Components\Fields\TextInput;
use Monstrex\Ave\Core\Components\Fields\Media;
use Monstrex\Ave\Core\Components\Columns\Column;
use Monstrex\Ave\Core\Components\Columns\ImageColumn;
use App\Models\Post;

class PostResource extends BaseResource
{
    public static string $model = Post::class;
    protected static ?string $slug = 'posts';

    public function fields(): array
    {
        return [
            TextInput::make('title')->

Media::make('gallery')
    ->multiple(true, maxFiles: 20)
    ->acceptImages()
    ->maxFileSize(5120) // KB
    ->columns(8) // Grid layout
    ->props('title', 'alt', 'caption', 'position')
    ->conversions([
        'thumb' => ['width' => 150, 'height' => 150],
        'medium' => ['width' => 800],
        'large' => ['width' => 1920],
    ])
    ->pathStrategy('dated')
    ->pathPrefix('products')

// Or use a preset
Media::make('banner')->preset(SingleImagePreset::class)

Fieldset::make('team_members')
    ->schema([
        TextInput::make('name')->leImagePreset::class),
        Textarea::make('bio'),
    ])
    ->sortable()
    ->collapsible()
    ->minItems(1)
    ->maxItems(10)
    ->headTitle('name') // Use 'name' field as item title
    ->addButtonLabel('Add Team Member')

BelongsToSelect::make('parent_id')
    ->relationship('parent', 'title')
    ->hierarchical() // Requires parent_id and order columns
    ->nullable()
    ->where(fn($q) => $q->where('status', 'active'))

Column::make('price')
    ->inline('text', ['field' => 'price'])
    ->inlineRules('

// In a seeder or service provider
$accessManager->registerPermissions('posts', [
    'viewAny' => ['name' => 'View Posts List'],
    'view' => ['name' => 'View Post Details'],
    'create' => ['name' => 'Create Posts'],
    'update' => ['name' => 'Edit Posts'],
    'delete' => ['name' => 'Delete Posts'],
]);

$accessManager->allows($user, 'posts', 'create'); // boolean

class PostResource extends BaseResource
{
    protected function beforeCreate(array $data): array
    {
        $data['author_id'] = auth()->id();
        return $data;
    }

    protected function afterCreate($model): void
    {
        // Trigger notifications, etc.
    }

    protected function beforeUpdate($model, array $data): array
    {
        $data['updated_by'] = auth()->id();
        return $data;
    }
}

return [
    'route_prefix' => 'admin',
    'user_model' => \App\Models\User::class,
    'users_table' => 'users',

    'acl' => [
        'enabled' => true,
        'super_role' => 'admin',
        'cache_ttl' => 300,
    ],

    'pagination' => [
        'default_per_page' => 25,
        'per_page_options' => [10, 25, 50, 100],
    ],
];
bash
php artisan ave:install --force        # Overwrite existing files
php artisan ave:install --no-migrate   # Skip migrations
bash
php artisan ave:uninstall
bash
php artisan vendor:publish --tag=ave-views    # Blade templates
php artisan vendor:publish --tag=ave-lang     # Translations (en, ru)
php artisan vendor:publish --tag=ave-config   # Configuration
bash
cd vendor/monstrex/ave
php ../../../vendor/bin/phpunit