public static function getSpecFabric($id) { return Spec::where("fabric_id", "=", $id)->where("sort", "!=", 0)->orderBy("sort")->get(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check() && User::isAdmin(Auth::user())) { try { $spec = Spec::find($id); $spec->delete(); return ["result" => true, "msg" => "Spec deleted succesfully", "id" => $id]; } catch (QueryException $ex) { return ["result" => false, "msg" => "Cannot delete spec, already has an order"]; } } else { return ["result" => false, "msg" => "Session not found or not enought permissions"]; } }
public function getAjaxFabric($id) { if ($id == "any") { $fabric = Fabric::first(); $specs = Spec::getSpecFabric($fabric->id); $imgs = Image::getImageFabric($fabric->id); return ["result" => true, "msg" => "Fabric found", "fabric" => $fabric, "specs" => $specs, "images" => $imgs]; } else { $fabric = Fabric::find($id); $specs = Spec::getSpecFabric($fabric->id); $imgs = Image::getImageFabric($id); return ["result" => true, "msg" => "Fabric found", "fabric" => $fabric, "specs" => $specs, "images" => $imgs]; } }