Example #1
0
 /**
  * Stores Labs data
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store()
 {
     $input = Request::all();
     //print_r($input); die;
     $rules = ['title' => 'required', 'type' => 'required', 'lang' => 'required', 'file' => 'required'];
     $validator = Validator::make($input, $rules);
     if ($validator->fails() or empty($input['file'])) {
         // redirect our user back to the form with the errors from the validator
         $messages = $validator->messages();
         // redirect our user back to the form with the errors from the validator
         return redirect(url(URL::previous()))->withErrors($validator);
     } else {
         $new['title'] = $input['title'];
         $new['tags'] = $input['tags'];
         $new['type'] = $input['type'];
         $new['lang'] = $input['lang'];
         $new['format'] = Input::file('file')->getClientOriginalExtension();
         $new['size'] = Input::file('file')->getSize();
         $tmp_path = Input::file('file')->getRealPath();
         $fileName = uniqid() . '.' . $new['format'];
         $path = 'docs/';
         Input::file('file')->move(public_path() . '/' . $path, $fileName);
         $new['url'] = $path . $fileName;
         Docs::create($new);
         return redirect('docs/all');
         /*
                     //return var_dump($input);
                     //Image handling
                     $tmp_path = $input['thumbnail']->getRealPath();
                     $extension = $input['thumbnail']->getClientOriginalExtension();
         
                     $path = '/img/exp/' . uniqid() . '.' . $extension;
                     Image::make($tmp_path)->save(base_path() . '/public' . $path);
                     //Image::make($tmp_path)->resize(240, 180)->save(base_path().'/public'.$path);
                     $input['thumbnail'] = $path;
         
         
                     //Array
                     $input['target'] = arrayToString($input['target']);
                     $input['subject'] = arrayToString($input['subject']);
                     $input['id'] = getLastLabId();
         
                     //Package
                     unzipLab($input['package']->getRealPath(), getLastLabId());
                     if (isset($input['maintenance']))
            ($input['maintenance'] == 'on') ? $input['maintenance'] = '1' : $input['maintenance'] = '0';
                     ($input['queue'] == 'on') ? $input['queue'] = '1' : $input['queue'] = '0';
         
                     Labs::create($input);
                     return redirect('labs');
         */
     }
 }
Example #2
0
 /**
  * @return \Illuminate\View\View
  */
 public function edit()
 {
     $id = Route::getCurrentRoute()->parameters()['id'];
     $data['lab'] = Labs::find($id);
     $data['docs'] = Docs::all();
     $array = DocsLabs::where('lab_id', $id)->get();
     $docs = '';
     foreach ($array as $one) {
         $docs .= $one['doc_id'] . ', ';
     }
     $data['labs_docs'] = $docs;
     return view('labs.edit', compact('data'));
 }