예제 #1
0
 public function getBuildingFromResName($resName)
 {
     return $this->buildings()->where('buildings_id', BuildingType::where('resources_id', Resource::where('name', $resName)->first()->id)->first()->id)->first();
 }
예제 #2
0
 public function getResources()
 {
     try {
         $resourcesArray = [];
         $i = 1;
         $categories = ResourcesCategory::orderBy('category')->get();
         foreach ($categories as $category) {
             $resourcesArray[$i]['category'] = $category->category;
             $category_id = $category->id;
             $resources = Resource::where('category_id', $category_id)->where('active', 1)->orderBy('resource', 'ASC')->get();
             $resourcesArray[$i]['resources'] = $resources;
             $i++;
         }
         return $resourcesArray;
     } catch (\Exception $e) {
         throw new LambdaException('The resources could not be found', null, $e);
     }
 }
예제 #3
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @param ResourceTransformer $transformer
  * @return \Illuminate\Http\Response
  */
 public function show($id, ResourceTransformer $transformer)
 {
     $resources = Resource::where('category_id', $id)->where('active', 1)->get();
     return $this->respond(['data' => $transformer->transformCollection($resources->toArray())]);
 }
예제 #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreResourceRequest $request, $id)
 {
     // default resources cannot be changed
     // was there any change?
     $output = Resource::find($id);
     // get this Resource
     Resource::where('id', $id)->update($request->except(['_method', '_token']));
     $message = 'Resource with id "' . $id . '" updated';
     return \Redirect::route($this->view_idx)->with(['status' => $message]);
 }