Answer the question
In order to leave comments, you need to log in
How to create a model with property list based on migration in laravel 8?
There is a migration with a list of fields for a table, how can I create a model for this table so that a list with a description of these properties is added to this model.
An example from an old project that was inherited)
/**
* App\Role
*
* @property int $id
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $updated_at
* @property string $name
* @property string $description
* @property-read \Illuminate\Database\Eloquent\Collection|\App\User[] $users
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Role extends Model
{
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
//
}
Answer the question
In order to leave comments, you need to log in
/**
* App\Role
*
* @property int $id
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $updated_at
* @property string $name
* @property string $description
* @property-read \Illuminate\Database\Eloquent\Collection|\App\User[] $users
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Role whereUpdatedAt($value)
* @mixin \Eloquent
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question