/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validation = $this->validation($request->all()); if ($validation->fails()) { return redirect()->back()->withInput()->withErrors($validation); } if (!($request->file('artwork')->isValid() || $request->file('signature')->isValid())) { return redirect()->back()->withInput()->withErrors(['there went something wrong while uploading the pictures.']); } $auction = new Art(); $auction->fill($request->all()); $auction->slug = $this->slugify($request->input('title')); $auction->description_nl = $request->input('description'); $auction->description_en = $request->input('description'); $auction->condition_nl = $request->input('condition'); $auction->condition_en = $request->input('condition'); $auction->user_id = 1; $auction->artist_id = 1; $auction->style_id = 1; $auction->save(); //store the images $this->storeImage($auction, $request->file('artwork'), true); $this->storeImage($auction, $request->file('signature'), false); //store optional image if is set if ($request->file('optional_image')) { $this->storeImage($auction, $request->file('optional_image'), false); } return redirect()->route('art.index')->withSuccess('successfully made a new auction'); }
/** * Run the database seeds. * * @return void */ public function run() { for ($i = 0; $i < 15; $i++) { $auction = new Art(); $auction->user_id = 1; $auction->artist_id = 1; $auction->style_id = 1; $auction->title = "Dance of Time III"; $auction->slug = "Dance-of-Time-III-" . $i; $auction->description_nl = "description in het nederlands"; $auction->description_en = "description in het engels"; $auction->condition_nl = "Condition in het nederlands"; $auction->condition_en = "condition in het engels"; $auction->width = "30cm"; $auction->height = "70cm"; $auction->depth = "2.5cm"; $auction->color = "Bronze, patinated branze and gold"; $auction->date_of_creation = "1979"; $auction->est_low_price = 9500; $auction->est_high_price = 10500; $auction->buyout = 15000; $auction->sold = false; $auction->end_datetime = "2016-01-24 12:00:00"; $auction->save(); } }
public function addart(addArtRequest $request) { //img nog toevoegen + validate $data = $request->all(); $ending = Carbon::now()->addDays($data['duration']); $input = new Art(); $input->user_id = Auth::user()->id; $input->title = $data['title']; //$input->slug = $this->slugify($data['title'], "-"); $input->description = $data['description']; $input->condition = $data['condition']; $input->creation_y = $data['creation_y']; $input->dimensions = $data['dimensions']; $input->color = $data['color']; $input->style_id = $data['style_id']; $input->era_id = $data['era_id']; $input->artist = $data['artist']; $input->country = $data['country']; $input->birth = $data['birth']; $input->death = $data['death']; $input->price = $data['price']; $input->min = $data['min']; $input->max = $data['max']; $input->ending = $ending; $input->save(); foreach ($data['pic'] as $pic) { $destinationPath = 'pic/art/' . $input->id . '/'; $now = Carbon::now()->format('Y-m-d'); $extension = $pic->getClientOriginalExtension(); $fileName = rand(11111, 99999) . '-' . $now . '.' . $extension; // renameing image random name //fullpath = path to picture + date + filename + extension $fullPath = $destinationPath . $fileName; $pic->move($destinationPath, $fileName); $picInput = new Pictures(); $picInput->art_id = $input->id; $picInput->path = $fullPath; $picInput->save(); } return redirect()->route('new')->withSuccess('succesvol toegevoegt'); }