PHP code example of laravilt / panel
1. Go to this page and download the library: Download laravilt/panel 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/ */
laravilt / panel example snippets
// app/Laravilt/Admin/Clusters/Settings.php
class Settings extends Cluster
{
protected static ?string $navigationIcon = 'Settings';
protected static ?string $navigationLabel = 'Settings';
}
class ProfilePage extends Page
{
protected static ?string $cluster = Settings::class;
}
class ProductResource extends Resource
{
public static function api(ApiResource $api): ApiResource
{
return ProductApi::configure($api);
}
}
class ProductApi
{
public static function configure(ApiResource $api): ApiResource
{
return $api
->columns([
ApiColumn::make('id')->type('integer')->sortable(),
ApiColumn::make('name')->searchable()->sortable(),
ApiColumn::make('price')->type('decimal'),
ApiColumn::make('created_at')->type('datetime'),
])
->useAPITester(); // Enable interactive API tester UI
}
}
$api->useAPITester(); // Enable
$api->useAPITester(false); // Disable (default)
$api
->columns([...]) // Define API columns
->endpoint('/api/products') // Custom endpoint
->perPage(25) // Items per page
->authenticated() // Require authentication
->list(enabled: true) // Enable/disable list operation
->show(enabled: true) // Enable/disable show operation
->create(enabled: true) // Enable/disable create operation
->update(enabled: true) // Enable/disable update operation
->delete(enabled: true) // Enable/disable delete operation
->useAPITester(); // Enable API Tester interface
use Laravilt\Panel\Panel;
use App\Models\Team;
Panel::make('admin')
->path('admin')
->tenant(Team::class, 'team', 'slug');
use Laravilt\Panel\Panel;
use Laravilt\Panel\Models\Tenant;
Panel::make('admin')
->path('admin')
->multiDatabaseTenancy(Tenant::class, 'myapp.com')
->tenantRegistration() // Allow new tenant signup
->tenantProfile() // Enable team settings page
->tenantModels([
\App\Models\Customer::class,
\App\Models\Product::class,
]);
use Laravilt\Panel\Models\Tenant;
$tenant = Tenant::create([
'name' => 'Acme Corp',
'owner_id' => $user->id,
]);
// Auto-generated: id, slug, database name
$tenant->addUser($user, 'admin');
$tenant->setSetting('feature.enabled', true);
$tenant->onTrial(); // Check trial status
// config/laravilt-tenancy.php
return [
'mode' => env('TENANCY_MODE', 'single'),
'subdomain' => [
'domain' => env('APP_DOMAIN', 'localhost'),
'reserved' => ['www', 'api', 'admin'],
],
'tenant' => [
'database_prefix' => 'tenant_',
'auto_migrate' => true,
],
];
bash
php artisan vendor:publish --tag="laravilt-panel-config"
bash
php artisan laravilt:panel admin
bash
php artisan laravilt:resource admin
bash
php artisan laravilt:page admin Dashboard
bash
php artisan laravilt:cluster admin Settings --icon=Settings
bash
php artisan vendor:publish --tag=laravilt-tenancy-config
bash
php artisan laravilt:filament
app/Laravilt/Admin/Resources/Product/
├── ProductResource.php # Main resource class
├── Form/
│ └── ProductForm.php # Form configuration
├── Table/
│ └── ProductTable.php # Table configuration
├── InfoList/
│ └── ProductInfoList.php # Infolist configuration
├── Api/
│ └── ProductApi.php # API configuration (optional)
└── Pages/
├── ListProduct.php # List page
├── CreateProduct.php # Create page
├── EditProduct.php # Edit page
└── ViewProduct.php # View page
bash
composer analyse