PHP code example of christyoga123 / vuelament

1. Go to this page and download the library: Download christyoga123/vuelament 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/ */

    

christyoga123 / vuelament example snippets


// app/Vuelament/Admin/User/Resources/ListUsers.php
use ChristYoga123\Vuelament\Core\Pages\ListRecords;
use ChristYoga123\Vuelament\Components\Actions\CreateAction;

class ListUsers extends ListRecords
{
    protected static ?string $resource = UserResource::class;

    public static function getHeaderActions(): array
    {
        return [
            CreateAction::make(),
            // ExportAction::make(),
            // ImportAction::make(),
        ];
    }
}

public static function getPages(): array
{
    return [
        // CRUD page classes — framework reads getHeaderActions() from these
        'index'  => Resources\ListUsers::class,
        'create' => Resources\CreateUser::class,
        'edit'   => Resources\EditUser::class,

        // Custom pages
        'report' => Pages\ReportPage::route('/{record}/report'),
    ];
}

public static function tableSchema(): PageSchema
{
    return PageSchema::make()
        ->components([
            Table::make()
                ->query(fn() => User::query()->latest())
                ->columns([
                    TextColumn::make('name')->searchable()->sortable(),
                    TextColumn::make('email')->sortable()->searchable(),
                    ToggleColumn::make('is_active')->label('Active'),
                ])
                ->actions([
                    // ✅ Row-level actions (inline in table)
                    Action::make('deactivate')
                        ->icon('user-x')
                        ->color('warning')
                        ->

use ChristYoga123\Vuelament\Components\Layout\Grid;
use ChristYoga123\Vuelament\Components\Layout\Section;
use ChristYoga123\Vuelament\Components\Form\TextInput;
use ChristYoga123\Vuelament\Components\Form\Toggle;

public static function formSchema(): PageSchema
{
    return PageSchema::make()
        ->components([
            Section::make('General Information')
                ->components([
                    Grid::make(2)->components([
                        TextInput::make('name')->te))
                        ->saved(fn (?string $state): bool => filled($state))
                        ->

Action::make('deactivate')
    ->icon('user-x')
    ->color('warning')
    ->

// app/Vuelament/Admin/User/Services/UserService.php
class UserService
{
    public function deactivate(User $user, array $data = []): void
    {
        $user->update(['is_active' => false]);
    }
}

$instance = app(UserService::class);

app()->call([$instance, 'deactivate'], [
    'user'   => $record,    // injected by lowercase model basename
    'record' => $record,    // also available as generic 'record'
    'data'   => $formData,  // form data from modal
]);

Action::make('assign_role')
    ->icon('shield')
    ->color('success')
    ->form([
        Select::make('role')->options([
            'admin' => 'Admin',
            'editor' => 'Editor',
        ])->

Toggle::make('is_active')->label('Active Status'),

// Shows INSTANTLY when is_active is toggled on (no server request!)
TextInput::make('activation_code')
    ->visibleWhen('is_active', true)
    ->m'),

use ChristYoga123\Vuelament\Components\Table\Actions\Action;

Action::make('form')
    ->icon('form')
    ->color('success')
    ->label('Fill Form')
    ->modalHeading('Detailed User Form')
    ->modalWidth('4xl')
    ->modalCloseByClickingAway(false)
    ->modalCancelActionLabel('Close')
    ->form([
        TextInput::make('reference_id')->

use ChristYoga123\Vuelament\Core\Panel;

class User extends Authenticatable
{
    public function hasPanelAccess(Panel $panel): bool
    {
        // Example: Only let users with role 'admin' access the Admin panel
        if ($panel->getId() === 'admin') {
            return $this->role === 'admin';
        }

        // Example: Only let 'sales' role access the Sales panel
        if ($panel->getId() === 'sales') {
            return $this->role === 'sales';
        }

        return true; // Default access
    }
}

use ChristYoga123\Vuelament\Core\BasePage;

class AnalyticsPage extends BasePage
{
    protected static ?string $navigationIcon = 'activity';
    protected static ?string $navigationLabel = 'Live Analytics';
    protected static string $slug = 'analytics';

    public static function getData(?\Illuminate\Database\Eloquent\Model $record = null): array
    {
        return [
            'totalUsers' => User::count(),
            'revenue' => 5000000,
        ];
    }
}

// config/vuelament.php
return [
    'default_panel' => 'admin',
    'user_model' => \App\Models\User::class,
    'app_path' => 'Vuelament',
    'assets' => [
        'auto_publish' => true,
    ],
];
bash
php artisan vuelament:install
bash
php artisan vendor:publish --tag=vuelament-views
bash
php artisan migrate
php artisan vuelament:user
npm run dev
php artisan serve

app/Vuelament/{Panel}/{Model}/
    ├── Resources/              ← CRUD page classes (like Filament)
    │    ├── List{Model}s.php        → getHeaderActions(): [CreateAction::make()]
    │    ├── Create{Model}.php       → getHeaderActions(), getFormActions()
    │    └── Edit{Model}.php         → getHeaderActions(), getFormActions()
    │
    ├── Pages/                  ← Custom pages (non-CRUD)
    │
    ├── Services/               ← Business logic (service-based actions)
    │    └── {Model}Service.php
    │
    ├── Widgets/                ← Dashboard widgets
    │
    └── {Model}Resource.php     ← Form schema, table schema, getPages()

app/Vuelament/Admin/Product/
    ├── Resources/
    │    ├── ListProducts.php       ← with CreateAction in getHeaderActions()
    │    ├── CreateProduct.php
    │    └── EditProduct.php
    ├── Pages/
    ├── Services/
    │    └── ProductService.php
    ├── Widgets/
    └── ProductResource.php         ← with getPages() referencing page classes
bash
php artisan vuelament:panel Sales --id=sales
bash
php artisan vuelament:user
bash
php artisan vuelament:panel Sales --id=sales
bash
php artisan vuelament:resource Invoice --panel=Sales
bash
php artisan vuelament:page Analytics --panel=Admin
bash
php artisan vendor:publish --tag=vuelament-config
bash
php artisan vendor:publish --tag=vuelament-stubs