public function destroy(Minute $minutes) { if (file_exists($this->destinationDir . '/' . $minutes->pdf)) { unlink($this->destinationDir . '/' . $minutes->pdf); } $minutes->delete(); return response()->json('', Response::HTTP_NO_CONTENT); }
public function testPatchMinutes() { $location = factory(Location::class)->create(); $minuteObject = factory(Minute::class)->create(['location_id' => $location->id]); $minuteObject->start = '2011-10-10 19:00:00'; $minuteData = json_encode(['data' => ['type' => 'minutes', 'attributes' => $minuteObject->toArray(), 'relationships' => ['location' => ['data' => ['type' => 'locations', 'id' => $location->id]]]]]); $response = $this->callPatch(self::API_URL . $minuteObject->id, $minuteData); $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); $this->assertNotNull($minute = json_decode($response->getContent())->data); $this->assertNotEmpty($minute->id); // test to make sure the user was created $updatedMinute = Minute::findOrFail($minute->id); $this->assertEquals('2011-10-10 19:00:00', $updatedMinute->start); }