Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created May 18, 2018 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/f1748932010c51ca35660d5097abd29a to your computer and use it in GitHub Desktop.
Save whoisryosuke/f1748932010c51ca35660d5097abd29a to your computer and use it in GitHub Desktop.
Laravel - Add a hook script to the Model. In this case, we generate a UUID on creation.
/**
* Setup model event hooks
*/
public static function boot()
{
parent::boot();
self::creating(function ($table) {
// Generate uuid
$table->uuid = Uuid::generate(4);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment