A simple free alternative for Laravel Nova.
composer require internexus/larapid
php artisan vendor:publish --tag=larapid
<?php
namespace App\Providers;
use App\Entities\UserEntity;
use Illuminate\Support\ServiceProvider;
use Internexus\Larapid\Facades\Larapid;
class LarapidServiceProvider extends ServiceProvider
{
public function register()
{
Larapid::entities([
UserEntity::class,
]);
}
}
<?php
namespace App\Entities;
use App\Models\User;
use Internexus\Larapid\Entities\Entity;
use Internexus\Larapid\Fields\Email;
use Internexus\Larapid\Fields\Password;
use Internexus\Larapid\Fields\Text;
class UserEntity extends Entity
{
public static $model = User::class;
public static $title = 'Usuários';
public function fields() {
return [
Text::make('Nome', 'name')->rules('required'),
Email::make('E-mail', 'email')->rules('required|email|max:255'),
Password::make('Senha', 'password')->rules('required|min:6|max:255'),
];
}
}
Text::make('Label', 'column')
Date::make('Created at', 'created_at')
Datetime::make('Created at', 'created_at')
Boolean::make('Public')
Email::make('E-mail')
Password::make('Password')
Url::make('Url')
Money::make('Price')
Number::make('Price')->min(10)->max(100)
Select::make('Status')->options([1 => 'Approved', 2 => 'Cancelled'])
Textarea::make('Content')
Media::make('Featured image', 'media_id')
->accept(['jpg', 'png'])
->maxSize(100000) // in bytes
->minDimension(100, 100)
->maxDimension(1920, 1080)
HasMany::make('User posts', 'user_id', PostEntity::class, 'posts')
BelongsTo::make('User role', 'role_id', UserEntity::class)
help(string $text)
readOnly()
placeholder(string $placeholder)
rules(array $rules)
creationRules(array $rules)
updateRules(array $rules)
showOnIndex()
showOnDetail()
showOnCreating()
showOnUpdating()
hideFromIndex()
hideFromDetail()
hideWhenCreating()
hideWhenUpdating()
onlyOnIndex()
onlyOnDetail()
onlyOnForms()
exceptOnForms()
sortable()
searchable()
fieldsForIndex()
fieldsForDetail()
fieldsForCreating()
fieldsForUpdating()
enableEditing()
enableDetail()
enableDeleting()
beforeSaving()
afterCreated()
afterUpdated()
redirectAfterCreate(Model $model)
redirectAfterUpdate(Model $model)
redirectAfterDelete(Model $model)