/**
  * testDestroyRecord.
  *
  * Delete last car inserted.
  *
  * Assert that delete method returns true
  *
  * assert that returned getAll array has 4 cars
  *
  * Assert that car with id of 5 is not in cars table
  *
  * @return [type] [description]
  */
 public function testDestroyRecord()
 {
     $deleteCar = Car::destroy(5);
     $cars = Car::getAll();
     $this->assertTrue($deleteCar);
     $this->assertEquals(4, count($cars));
     $this->AssertNotContains(5, $cars);
     $this->AssertNotContains('Beetle', $cars);
 }
Ejemplo n.º 2
0
function deleteCar($id)
{
    $car = Car::destroy($id);
    echo "done";
}
Ejemplo n.º 3
0
 /**
  * Remove the specified car from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Car::destroy($id);
     return Redirect::route('cars.index');
 }
Ejemplo n.º 4
0
 /**
  * Remove the specified car from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $userId = Auth::user()->id;
     $carData = Car::find($id);
     if ($userId === $carData["user_id"]) {
         Log::info("userid: {$userId}, car: {$id} Deleted.");
         $carParking = DB::table('car_parking_lots')->where('car_id', $id);
         $carParking->delete();
         Car::destroy($id);
         return Redirect::route('cars.index');
     } else {
         return "Access Denied: this is not your car.";
     }
 }