Ejemplo n.º 1
0
 public function get_proposale($id)
 {
     $selected_program_id = $id;
     $selected_program = Program::find($selected_program_id);
     if (!$selected_program) {
         $selected_program_id = Program::first()->id;
         $selected_program = Program::find($selected_program_id);
     }
     $selected_vacation = Vacation::where('program_id', '=', $selected_program_id)->first();
     $selected_vacation_id = $selected_vacation->id;
     $programs = Program::all();
     $vacations = Vacation::where('program_id', '=', $selected_program_id)->get();
     $parts = Part::where('vacation_id', '=', $selected_vacation_id)->get();
     $user_id = Session::get('user_id');
     $childrens = Children::where('user_id', '=', $user_id)->get();
     $all_news = News::where('active', '=', '1')->get();
     return view('user.proposale')->with('selected_program', $selected_program)->with('selected_vacation', $selected_vacation)->with('programs', $programs)->with('vacations', $vacations)->with('parts', $parts)->with('childrens', $childrens)->with('all_news', $all_news);
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store($story, CreatePart $request)
 {
     $input = $request->all();
     $story_id = $story;
     $part = new part();
     $part->story_id = $story_id;
     $part->title = $input['title'];
     $part->description = $input['description'];
     //place of part
     $position = 0;
     $current_position = Part::where('story_id', $story)->pluck('position');
     if (empty($current_positioncount)) {
         $current_position = 0;
     } else {
         $current_position;
     }
     //current_position = 1
     if ($position <= $current_position) {
         $position = $current_position + 1;
         //expect position to go to 2
     } else {
         $position = $current_position;
     }
     $part->position = $position;
     //setting position 2
     $part->save();
     //image
     $destinatonPath = '';
     $filename = '';
     $file = Input::file('image');
     $destinationPath = public_path() . '/images/parts';
     $filename = $part->id . '_' . $file->getClientOriginalName();
     $uploadSuccess = $file->move($destinationPath, $filename);
     $addimage = Part::find($part->id);
     $addimage->image = $filename;
     $addimage->save();
     return redirect('story/' . $story . '/edit');
 }
Ejemplo n.º 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $vacation = Vacation::find($id);
     $program_id = $vacation->program_id;
     $parts = Part::where('vacation_id', '=', $vacation->id)->get();
     return view('admin.edit_vacation', ['vacation' => $vacation, 'program_id' => $program_id, 'parts' => $parts]);
 }
Ejemplo n.º 4
0
 public function get_vacation($id)
 {
     $vacation = Vacation::find($id);
     $parts = Part::where('vacation_id', '=', $id)->get();
     return $parts->toJson();
 }