Skip to content

Instantly share code, notes, and snippets.

@dwihujianto
Created December 20, 2018 03:01
Show Gist options
  • Save dwihujianto/93b246b35a026cf773f1364697c2e05e to your computer and use it in GitHub Desktop.
Save dwihujianto/93b246b35a026cf773f1364697c2e05e to your computer and use it in GitHub Desktop.
<?php
// model student
class Student extends Model
{
}
// user oberserver
class UserObserver
{
public function saved(user)
{
Student::create([
'name' => $user->name,
'email' => $user->email
]);
}
}
// model user
class User extends Model
{
public static function boot()
{
parent::boot();
self::observe(new UserObserver());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment