public function edit()
 {
     $user = User::findOrFail(Auth::user()->id);
     $entity = Entity::where('user_id', Auth::user()->id)->firstOrFail();
     $about = About::where('user_id', Auth::user()->id)->firstOrFail();
     $contact = Contact::where('user_id', Auth::user()->id)->firstOrFail();
     $home = Home::where('user_id', Auth::user()->id)->firstOrFail();
     $quote = Quote::where('user_id', Auth::user()->id)->get();
     $quote_count = $quote->count();
     $skill = Skill::where('user_id', Auth::user()->id)->get();
     $skill_count = $skill->count();
     $skill_slider = SkillSlider::where('user_id', Auth::user()->id)->get();
     $skill_slider_count = $skill_slider->count();
     $portfolio_piece = PortfolioPiece::where('user_id', Auth::user()->id)->get();
     $portfolio_piece_count = $portfolio_piece->count();
     return view('edit')->with('user', $user)->with('home', $home)->with('entity', $entity)->with('contact', $contact)->with('about', $about)->with('skill', $skill)->with('skill_count', $skill_count)->with('quote', $quote)->with('quote_count', $quote_count)->with('skill_slider', $skill_slider)->with('skill_slider_count', $skill_slider_count)->with('portfolio_piece', $portfolio_piece)->with('portfolio_piece_count', $portfolio_piece_count);
 }
 public function updateHome()
 {
     $user = User::find(Auth::user()->id);
     $home = Home::where('user_id', Auth::user()->id)->firstOrFail();
     if (isset($user) && $home != NULL) {
         if (Input::get('title') != '') {
             $home->title = Input::get('title');
         }
         if (Input::get('caption') != '') {
             $home->caption = Input::get('caption');
         }
         if (Input::get('image_id') != '') {
             $home->image_id = Input::get('image_id');
         }
         if (Input::get('video_url') != '') {
             $home->video_url = Input::get('video_url');
         }
         $home->save();
         return redirect('home')->with('status', 'success');
     } else {
         return 'An error has occured';
     }
 }
Beispiel #3
0
 public function getAll($where = [])
 {
     $home_get = \App\Home::where($where);
     $home = $home_get->get();
     return $home;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function crear(Request $request)
 {
     $data = $request->all();
     $actividad = new Activity_Stage();
     $actividad->stage_project_id = $data['project_stage_id'];
     $actividad->activity_id = $data['activity_id'];
     $actividad->unity = $data['unity'];
     $actividad->other_unity = $data['other_unity'];
     $actividad->quantity = $data['quantity'];
     $actividad->material = $data['material'];
     $actividad->hand = $data['hand'];
     $actividad->transport = $data['transport'];
     $actividad->save();
     $project = Project::find($data['project_id']);
     $homes = Home::where('project_id', '=', $project->id)->get();
     foreach ($homes as $home) {
         $avance = new Advanced();
         $avance->porcent = 0.0;
         $avance->state = 4;
         $avance->home_id = $home->id;
         $avance->project_stage_id = $actividad->stage_project_id;
         $avance->save();
     }
     $all = Activity_Stage::join('project_stage', 'project_stage.id', '=', 'activity_stage.stage_project_id')->join('projects', 'projects.id', '=', 'project_stage.project_id')->where('projects.id', '=', $project->id)->get(['activity_stage.*']);
     $valor_total = 0;
     foreach ($all as $a) {
         $valor = 0;
         $valor += $a->hand + $a->transport + $a->material;
         $valor_total += $valor * $a->quantity;
     }
     $project->budget = 0;
     $project->budget = $valor_total;
     $project->save();
     return response()->json([$all]);
 }