<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Permission.
*
* @property int $id
* @property int $role_id
* @property string $name
*
* @method static where(string $string, string $uid)
*/
class Permission extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
];
/**
* Bootstrap any application services.
*/
public static function boot()
{
parent::boot();
// Create uid when creating list.
static::creating(function ($item) {
// Create new uid
$uid = uniqid();
while (self::where('uid', $uid)->count() > 0) {
$uid = uniqid();
}
$item->uid = $uid;
});
}
}