Exemplo n.º 1
0
 public function index()
 {
     $portfolios = Portfolio::orderBy('group_id', 'ASC')->orderBy('position', 'ASC')->get();
     $portfolio = new Portfolio();
     if (Request::isMethod('post')) {
         $validator = Validator::make(Request::all(), $this->rules);
         if ($validator->passes()) {
             $portfolio->title = Request::input('title');
             $portfolio->titleEng = Request::input('titleEng');
             $portfolio->announce = Request::input('announce');
             $portfolio->announceEng = Request::input('announceEng');
             $portfolio->text = Request::input('text');
             $portfolio->textEng = Request::input('textEng');
             $portfolio->group_id = Request::input('group');
             $portfolio->position = Request::input('position');
             $portfolio->enabled = Request::has('enabled');
             if ($file = Request::file('photo')) {
                 $portfolio->photo = $this->upload($file, 'photo');
             }
             if ($file = Request::file('preview')) {
                 $portfolio->preview = $this->upload($file, 'photo');
             }
             $portfolio->save();
             return redirect('admin/portfolio')->with('msg', 'Портфолио было успешно создано');
         } else {
             return redirect('admin/portfolio')->withInput()->withErrors($validator);
         }
     }
     return view('admin.portfolio', ['portfolios' => $portfolios, 'portfolio' => $portfolio]);
 }
Exemplo n.º 2
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Portfolio::$rules);
     if ($validator->passes()) {
         $portfolio_item = new Portfolio();
         $portfolio_item->title = Input::get('title');
         $portfolio_item->url = Input::get('url');
         $portfolio_item->short_description = Input::get('short_description');
         $portfolio_item->long_description = Input::get('long_description');
         $portfolio_item->on_the_home = (int) Input::get('on_the_home');
         $portfolio_item->save();
         flash()->success("Элемент Ядобавлен");
         return Redirect::to("/admin/portfolio/edit/{$portfolio_item->id}");
     }
     flash()->error("Ошибка");
     return Redirect::back();
 }