trevorpan
1 month ago
272
4
Testing

add HasFactory trait to Model::class() vs. each model?

Posted 1 month ago by trevorpan

If each model extends:

<?php

namespace App\Models;

...

class Order extends Model
{

Is it reasonable to just add it to the Model class?

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as Eloquent;

class Model extends Eloquent
{
    use HasFactory;
    protected $guarded = [];
}

Please sign in or create an account to participate in this conversation.