I have the following trait:
<?php
namespace App\Traits;
trait SlugGenerator
{
public static $slugAttributes;
public static function bootSlugGenerator()
{
static::creating(function ($model) {
if(isset(self::$slugAttributes)){
$model->slug = 'a';
} else {
$model->slug = 'b';
}
});
}
}
And here I call my trait:
<?php
namespace App\Models;
use App\Traits\SlugGenerator;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use SlugGenerator;
protected static $slugAttributes = [
'first_name',
'last_name'
];
}
But I get the following error:
App\Models\User and App\Traits\SlugGenerator define the same property ($slugAttributes) in the composition of App\Models\User. However, the definition differs and is considered incompatible. Class was composed
How to override the $slugAttributes
variable?