class Student extends Model
{
use HasFactory;
protected $guarded=[''];
public function user()
{
return $this->belongsTo(User::class);
}
public function family()
{
return $this->hasOne(Family::class);
}
public function addition()
{
return $this->hasOne(Addition::class);
}
public static function boot() {
parent::boot();
static::deleting(function($user) { // before delete() method call this
$user->family()->delete();
$user->addition()->delete();
// do the rest of the cleanup...
});
}
}
0 Komentar