public function add() { $file = Request::file('file'); if (Request::hasFile('file')) { $extension = $file->getClientOriginalExtension(); Storage::disk('local')->put($file->getFilename() . '.' . $extension, File::get($file)); $entry = new \App\File(); $entry->mime = $file->getClientMimeType(); $entry->original_filename = $file->getClientOriginalName(); $entry->filename = $file->getFilename() . '.' . $extension; $entry->save(); $part = new Part(); $part->file_id = $entry->id; $part->name = Request::input('name'); $part->sku = Request::input('sku'); $part->make = Request::input('make'); $part->year = Request::input('year'); $part->condition = Request::input('condition'); $part->description = Request::input('description'); $part->price = Request::input('price'); $part->imageurl = Request::input('imageurl'); if (Request::has('price')) { $part->save(); } } return redirect('/admin/part'); }
/** * 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'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $part = Part::find($id); $vacation_id = $part->vacation_id; $part->delete(); return redirect('/admin/programs/vacation/' . $vacation_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]); }
/** * 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]); }
public function get_vacation($id) { $vacation = Vacation::find($id); $parts = Part::where('vacation_id', '=', $id)->get(); return $parts->toJson(); }
public function getParts() { $parts = Part::all(); return view('pages.parts', ['parts' => $parts]); }