/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $spares = Spares::find($id);
     $cars_spares = $spares->cars->lists('id')->toArray();
     $cars = Cars::lists('name', 'id');
     $data = array('spares' => $spares, 'cars' => $cars);
     return View::make('spares.edit')->with($data);
     //,'cars_spares', $cars_spares
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $cars = Cars::find($id);
     $cars->delete();
     // redirect
     Session::flash('message', 'Successfully deleted the cars!');
     return Redirect::to('cars');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $order = Order::count();
     $supply = Supply::count();
     $spares = Spares::count();
     $car = Cars::count();
     $data = array('order' => $order, 'supply' => $supply, 'spares' => $spares, 'car' => $car);
     if ($this->manager) {
         return View::make('dashbord.manager')->with($data);
     } else {
         if ($this->salesman) {
             return View::make('dashbord.salesman')->with($data);
         } else {
             return redirect('/login');
         }
     }
 }