/** * @test */ public function canDeleteAddress() { $address = $this->guardian()->addresses()->orderBy('created_at', 'DESC')->first(); // Because of the dropdown menu's functionality for delete being // in javascript we'll have to simulate the request $address->delete(); // bypassing caching, see above comments $this->assertEquals(0, Address::where('id', $address->id)->count()); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return Address::where('id', $this->route('address'))->where('user_id', Auth::id())->exists(); }