internexus / larapid
A simple free alternative for Laravel Nova.
1.0.10-alpha
2022-07-05 00:25 UTC
Requires
- php: ^7.2.5|^8.0
- illuminate/support: ^7.0|^8.0
- inertiajs/inertia-laravel: ^0.4.4
- intervention/image: ^2.7
- laravel/ui: ^3.4
Requires (Dev)
- mockery/mockery: ^1.3.3|^1.4.2
This package is auto-updated.
Last update: 2024-11-05 05:54:47 UTC
README
A simple free alternative for Laravel Nova.
Install
Installing via Composer
composer require internexus/larapid
Publish packages resources
php artisan vendor:publish --tag=larapid
Usage
Create a service provider
<?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, ]); } }
Create an entity
<?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'), ]; } }
Fields
Text
Text::make('Label', 'column')
Date
Date::make('Created at', 'created_at')
Datetime
Datetime::make('Created at', 'created_at')
Boolean
Boolean::make('Public')
Email::make('E-mail')
Password
Password::make('Password')
Url
Url::make('Url')
Money
Money::make('Price')
Number
Number::make('Price')->min(10)->max(100)
Select
Select::make('Status')->options([1 => 'Approved', 2 => 'Cancelled'])
Textarea
Textarea::make('Content')
Media
Media::make('Featured image', 'media_id') ->accept(['jpg', 'png']) ->maxSize(100000) // in bytes ->minDimension(100, 100) ->maxDimension(1920, 1080)
HasMany
HasMany::make('User posts', 'user_id', PostEntity::class, 'posts')
BelongsTo
BelongsTo::make('User role', 'role_id', UserEntity::class)
Available Fields methods
Attributes
help(string $text)
readOnly()
placeholder(string $placeholder)
Validations
rules(array $rules)
creationRules(array $rules)
updateRules(array $rules)
Visibility
showOnIndex()
showOnDetail()
showOnCreating()
showOnUpdating()
hideFromIndex()
hideFromDetail()
hideWhenCreating()
hideWhenUpdating()
onlyOnIndex()
onlyOnDetail()
onlyOnForms()
exceptOnForms()
Search and sort
sortable()
searchable()
Available Entity methods
Visibility
fieldsForIndex()
fieldsForDetail()
fieldsForCreating()
fieldsForUpdating()
Actions
enableEditing()
enableDetail()
enableDeleting()
Hooks
beforeSaving()
afterCreated()
afterUpdated()
Redirects
redirectAfterCreate(Model $model)
redirectAfterUpdate(Model $model)
redirectAfterDelete(Model $model)