so I have a relationship between two models
class Projects extends Model implements Auditable
{
use SoftDeletes;
use \OwenIt\Auditing\Auditable;
protected $fillable = [
'name', 'active'
];
public function boards(){
return $this->belongsTo(Board::class);
}
}
And
class Board extends Model
{
protected $guarded = [];
public function projects(){
return $this->hasMany(Projects::class);
}
}
I wanted to empty the Board from its Projects without deleting the relationship. I thought this code would do the trick:
$board->projects()->delete()
But I ended up deleting the relationship.
My question now is how do I restore the relationship and what would be the best way to empty the relationship without actually deleting it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire