예제 #1
0
 /**
  * Store a newly created Restaurantes in storage.
  *
  * @param CreateRestaurantesRequest $request
  *
  * @return Response
  */
 public function store(CreateRestaurantesRequest $request)
 {
     $file = $request->file('imagen');
     $restaurante = new Restaurantes($request->all());
     if (!is_null($file)) {
         $nombre = Carbon::now() . '_' . $file->getClientOriginalName();
         //TODO comprobar extensión
         Storage::disk('restaurantes')->put($nombre, File::get($file));
         //TODO Internacionalizar
         $restaurante->imagen = $nombre;
     }
     $restaurantes = $this->restaurantesRepository->create($restaurante->toArray());
     Flash::success('Restaurantes saved successfully.');
     return redirect(route('restaurantes.index'));
 }
예제 #2
0
 public function search($input)
 {
     $query = Restaurantes::query();
     $columns = Schema::getColumnListing('restaurantes');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }