/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $range = Range::find($id);
     if (!$range) {
         return response()->json('La gamme n\'existe pas.', 404);
     }
     $range->delete();
     return 'La gamme a bien été supprimée.';
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $product = Product::find($id);
     if (!$product) {
         return response()->json('Le produit n\'existe pas.', 404);
     }
     $validator = Validator::make($request->all(), ['range_id' => 'integer', 'project_id' => 'integer']);
     if ($validator->fails()) {
         return response()->json($validator->errors()->all(), 400);
     }
     if ($request->input('range_id')) {
         try {
             $range = Range::findOrFail($request->input('range_id'));
         } catch (Exception $e) {
             return response()->json('La gamme n\'existe pas.', 404);
         }
     }
     if ($request->input('project_id')) {
         try {
             $project = Project::findOrFail($request->input('project_id'));
         } catch (Exception $e) {
             return response()->json('Le projet n\'existe pas.', 404);
         }
     }
     $product->update($request->all());
     return $product;
 }