limoncello-php / app

Quick start JSON API application
MIT License
83 stars 7 forks source link

forbidden field in model #64

Open dreamsbond opened 4 years ago

dreamsbond commented 4 years ago

I have a scenario where the UUID should be being created or updated by the user. Is there any declaration exists for making the UUID only readable so to restrict user from creating and updating it?

dreamsbond commented 4 years ago

something like

 protected $guarded = ['uuid'];

in laravel

dreamsbond commented 4 years ago

and followed by the guarded field.

is it possible to achieve

class User extends Model 
{

    public static function boot()
    {
        parent::boot();

        self::creating(function($model){
            // ... code here
        });

        self::created(function($model){
            // ... code here
        });

        self::updating(function($model){
            // ... code here
        });

        self::updated(function($model){
            // ... code here
        });

        self::deleting(function($model){
            // ... code here
        });

        self::deleted(function($model){
            // ... code here
        });
    }

}

like in laravel?

I would like to generate UUID automatically at the time of resource creating.