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))
->
// 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
]);
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
}
}