Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Set null" behavior #130

Open
rikipm opened this issue Aug 10, 2021 · 1 comment
Open

Add "Set null" behavior #130

rikipm opened this issue Aug 10, 2021 · 1 comment

Comments

@rikipm
Copy link

rikipm commented Aug 10, 2021

Add behavior similar to SET NULL action. It will set relation column to NULL when referenced model is deleted.

For example

Class User extends Model {
  use SoftDeletes, SoftCascadeTrait;
  
  protected $softCascade = ['phone@setNull'];
  
  public function phone()
  {
    return $this->hasOne(Phone::class);
  }
}

Class Phone extends Model {
   use SoftDeletes;
  
  public function user()
  {
    return $this->belongsTo(User::class);
  }
}

Will set NULL in phones.user_id if user was soft deleted.

@maguilar92
Copy link
Collaborator

You are free to make a PR with the improvement. I'm not using package anymore and only I will review PR's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants