Пример #1
0
 public function testDeleteOptionOnSoftModel()
 {
     Model::unguard();
     $user = UserWithAuthorAndSoftDelete::create(['name' => 'Stevie', 'email' => '*****@*****.**']);
     $author = Author::create(['name' => 'Louie', 'email' => '*****@*****.**', 'user_id' => $user->id]);
     Model::reguard();
     $authorId = $author->id;
     $user->delete();
     // Soft
     $this->assertNotNull(Author::find($authorId));
     // Do nothing
     $userId = $user->id;
     $user = UserWithAuthorAndSoftDelete::withTrashed()->find($userId);
     $user->restore();
     $user->forceDelete();
     // Hard
     $this->assertNull(Author::find($authorId));
 }