/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $spec = implode('-', $request->get('spec'));
     $item = new Items();
     $item->fill($request->all());
     $pieces = explode("-", $request->input('category'));
     $item->category_id = $pieces[1];
     $item->subcategory_id = $pieces[0];
     $item->spec = $spec;
     $slug = Helpers::makeSlug($request->input('title_geo'));
     $item->slug = $slug;
     $image = $request->file('main_image');
     $fileName = "";
     if ($image->isValid()) {
         $path = public_path() . '/uploads/item/';
         $fileName = str_random(32) . '.' . $image->getClientOriginalExtension();
         $image->move($path, $fileName);
     } else {
         App::abort(404);
     }
     $item->main_image = $fileName;
     $big_image = $request->file('big_image');
     $fileNameBig = "";
     if ($big_image->isValid()) {
         $path = public_path() . '/uploads/item/';
         $fileNameBig = str_random(32) . '.' . $big_image->getClientOriginalExtension();
         $big_image->move($path, $fileNameBig);
     } else {
         App::abort(404);
     }
     $item->main_image = $fileName;
     $item->big_image = $fileNameBig;
     $item->save();
     $item->ItemColors()->sync($request->color);
     $item->ItemSize()->sync($request->size);
     foreach ($request->file('images') as $p) {
         $fileName = "";
         if ($p->isValid()) {
             $path = public_path() . '/uploads/photos/' . $item->id . '/';
             $fileName = str_random(32) . '.' . $p->getClientOriginalExtension();
             $p->move($path, $fileName);
         } else {
             App::abort(404);
         }
     }
     return Redirect::route('admin.item.show');
 }