/** * Deletes vacation entry from database and returns status in json response * * @param $id * @return array */ public function delete($id) { if ($vacation = $this->vacation->find($id)) { if ($vacation->delete()) { return ['status' => 200]; } return ['status' => 500]; } return ['status' => 404]; }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create($id) { $part = new Part(); $program_id = Vacation::find($id)->program_id; return view('admin.edit_part', ['part' => $part, 'program_id' => $program_id, 'vacation_id' => $id]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $vacation = Vacation::find($id); $program = Program::find($vacation->program_id); $vacation->delete(); return redirect('/admin/programs/' . $program->id . '/edit'); }
public function children_data_save() { $children_id = Input::get('children_id'); $children = Children::find($children_id); if (!$children) { $children = new Children(); } $children->surname = Input::get('surname'); $children->name = Input::get('name'); $children->patronymic = Input::get('patronymic'); $children->birthday_date = Input::get('birthday_date'); $children->document = Input::get('document'); $children->document_number = Input::get('document_number'); $proposales = Proposale::where('children_id', '=', $children_id)->count(); if ($proposales != 0) { $children->member = 1; } else { $children->member = 0; $children->marketing = Input::get('marketing'); } $children->registration = Input::get('registration'); $children->save(); $user_id = Input::get('id'); $proposale_id = Input::get('proposale_id'); $temporary_proposale = Temporary_proposale::find($proposale_id); $proposale = new Proposale(); $proposale->children_id = $children_id; $proposale->user_id = $user_id; $proposale->program_id = $temporary_proposale->program_id; $proposale->vacation_id = $temporary_proposale->vacation_id; $proposale->part_id = $temporary_proposale->part_id; $proposale->transfer = $temporary_proposale->transfer; $proposale->registration_date = $temporary_proposale->registration_date; $part = Part::find($temporary_proposale->part_id); $vacation = Vacation::find($temporary_proposale->vacation_id); $start_date = NULL; $finish_date = NULL; if ($vacation) { if ($part) { $start_date = $part->start_date; $finish_date = $part->finish_date; } else { $start_date = $vacation->start_date; $finish_date = $vacation->finish_date; } } $proposale->start_date = $start_date; $proposale->finish_date = $finish_date; $proposale->save(); $temporary_proposale->delete(); $all_news = News::where('active', '=', '1')->get(); return view('user.proposale_success', ['children' => $children, 'all_news' => $all_news, 'proposale' => $proposale]); }
public function get_vacation($id) { $vacation = Vacation::find($id); $parts = Part::where('vacation_id', '=', $id)->get(); return $parts->toJson(); }