Awesome
Laplus
Laravel plus+ add presentation for your models
public function present()
{
$this->id();
$this->text('title');
$this->string('password')->cast('hashed')->hidden();
$this->belongsTo(Artist::class)->cascadeOnDelete();
}
Write your presents in long time:
Laplus will generate your migrations:
Requirements
- Php 8.2 or higher
- Laravel 11.0
Documents
Installation
1- Install the package with composer:
composer require rapid/laplus
2- Publish configs
Run this command to publish configs to config/laplus.php
php artisan vendor:publish --tag=laplus
3- Convert default User model to presentable model (optional):
- Add
HasPresent
trait:
class User extends Model
{
use HasPresent;
}
- Remove
$fillable
,$hidden
andcasts()
values:
//protected $fillable = ['name', 'email', 'password'];
//protected $hidden = ['password', 'remember_token'];
//protected function casts() { ... }
Laplus will automatically add this values.
- Create
UserPresent
class with the following command:
php artisan make:user-present
Or add below code in User class:
protected function present(Present $present)
{
$present->id();
$present->string('name');
$present->string('email')->unique();
$present->timestamp('email_verified_at')->nullable();
$present->password();
$present->rememberToken();
$present->timestamps();
}
- Move default migration to laplus path:
Find database/migrations/0001_01_01_000000_create_users_table.php
file and move it
into database/migrations/auto_generated
folder (create it if doesn't exists)
Make model & present
You can use this command to create a model and a present:
php artisan make:model+ Name
This command will create app/Models/Name.php
model and app/Presents/NamePresent.php
present.
Make model with inline present
You can use this command to create a model with inline present:
php artisan make:model+ Name --inline
This command will create app/Models/Name.php
model.
Migrations
Generate Migrations
Run this command to automatically found the updates and generate migrations:
php artisan generate+
Regenerate Migrations
This command is same with generate+
, but the difference is clearing the migration folder!
php artisan regenerate+
Warning: This command will remove all your migration files (exclude files starts with
0001_01_01
name)
Generate And Migrate
Following command, run generate+
and migrate
at once:
php artisan migrate+
More Document
More document found in Documents section.