src/Database/Concerns/IsAbility.php
public static function makeForModel($model, $attributes)
    {
        if (is_string($attributes)) {
            $attributes = ['name' => $attributes];
        }

        if ($model === '*') {
            return (new static)->forceFill($attributes + [
                'entity_type' => '*',
            ]);
        }

        if (is_string($model)) {
            $model = new $model;
        }

        return (new static)->forceFill($attributes + [
            'entity_type' => $model->getMorphClass(),
            'entity_id'   => $model->exists ? $model->getKey() : null,
        ]);
    }
public static function makeForModel($model, $attributes)
    {
        if (is_string($attributes)) {
            $attributes = ['name' => $attributes];
        }

        if ($model === '*') {
            return (new static)->forceFill($attributes + [
                'entity_type' => '*',
            ]);
        }

        if (is_string($model)) {
            $model = new $model;
        }

        return (new static)->forceFill($attributes + [
            'entity_type' => $model->getMorphClass(),
            'entity_id'   => $model->exists ? $model->getKey() : null,
        ]);
    }
public static function makeForModel ( $ model , $ attributes ) { if ( is_string ( $ attributes ) ) { $ attributes = [ 'name' => $ attributes ] ; } if ( $ model === '*' ) { return ( new static ) -> forceFill ( $ attributes + [ 'entity_type' => '*' , ] ) ; } if ( is_string ( $ model ) ) { $ model = new $ model ; } return ( new static ) -> forceFill ( $ attributes + [ 'entity_type' => $ model -> getMorphClass ( ) , 'entity_id' => $ model -> exists ? $ model -> getKey ( ) : null , ] ) ; }
Make a new ability for a specific model.

@param  \Illuminate\Database\Eloquent\Model|string  $model
@param  string|array  $attributes
@return static
Make a new ability for a specific model .