Skip to content

Instantly share code, notes, and snippets.

@alixcan
Last active May 31, 2021 09:56
Show Gist options
  • Select an option

  • Save alixcan/59b151f642cefc5f5cb337a7fdf6ac6d to your computer and use it in GitHub Desktop.

Select an option

Save alixcan/59b151f642cefc5f5cb337a7fdf6ac6d to your computer and use it in GitHub Desktop.
Disable eloquent Creating, Updating, Saving, Deleting actions.
<?php
namespace App\Traits;
use Illuminate\Http\Request;
trait DisableDBEntries
{
/**
* The "booted" method of the model.
*
* @return void
*/
protected static function booted()
{
static::creating(function ($user) {
return false;
});
static::updating(function ($user) {
return false;
});
static::saving(function ($user) {
return false;
});
static::deleting(function ($user) {
return false;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment