cardosso4 / generate-model
Model generator for the laravel framework
v0.0.5
2024-06-03 22:06 UTC
Requires
- php: ^7.0 | ^8.0
- illuminate/console: >=6.0
- illuminate/database: >=6.0
- illuminate/support: >=6.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This library aims to facilitate the creation of the model file with the necessary data as shown in the example below.
This library supports the databases.
- Mysql
How to execute:
- To run this command, run in the terminal: php artisan generate:model {table_name}
- This command can be found in PHP artisan command list
Example of the result
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class users extends Model
{
public const FIELD_ID = 'id';
public const FIELD_NAME = 'name';
public const FIELD_ADDRESS_ID = 'address_id';
protected $fillable = [
self::FIELD_ID,
self::FIELD_NAME,
self::FIELD_ADDRESS_ID,
];
protected $casts = [
self::FIELD_ID => 'bigint',
self::FIELD_NAME => 'string',
self::FIELD_ADDRESS_ID => 'bigint',
];
/**
* Relationships
*/
public function address(){
$this->belongsTo(Address::class, 'address_id', 'id');
}
}
Package for installation
generate-model: Packagist