示例#1
0
 public function acttdb()
 {
     $data = array();
     $camino = public_path('img/tdb/');
     $id = Input::get('id');
     $tdb = TDB::find($id);
     $nombre = Input::get('nombre');
     $imagen = Input::file('imagen');
     $cambio = false;
     if ($tdb->nombre == $nombre) {
         $cambio = false;
     } else {
         $cambio = true;
     }
     if (Input::hasfile('imagen')) {
         File::delete($camino . $tdb->id . '.' . $tdb->extension);
         $ext = $imagen->getClientOriginalExtension();
         $imagen->move($camino, $id . '.' . $ext);
         $tdb->extension = $ext;
         $data['imagen'] = asset('/img/tdb/' . $id . '.' . $ext);
     } else {
         $data['imagen'] = '';
     }
     $tdb->nombre = $nombre;
     $query = $tdb->save();
     if ($cambio != false) {
         $data['nombre'] = $nombre;
     } else {
         $data['nombre'] = '';
     }
     return Response::json($data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->except('_token');
     $product = new Product($input);
     $product->category_id = Input::get('category');
     Auth::user()->products()->save($product);
     if (Input::hasfile('image')) {
         $file = Input::file('image');
         $file->move('upload', $product->id . '.png');
     }
     Session::flash('success', 'Product uploaded successfully.');
     return redirect('/product');
 }
示例#3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function save()
 {
     $artikel = new artikel();
     $artikel->id_user = Auth::user()->id;
     $artikel->title = Input::get('title');
     $artikel->content = Input::get('content');
     $artikel->slug = str_slug(input::get('title'));
     $artikel->id_artikel = Input::get('id_artikel');
     if (Input::hasfile('pict')) {
         $pict = date("YmdHis") . uniqid() . "." . Input::file('pict')->getClientOriginalExtension();
         Input::file('pict')->move(storage_path(), $pict);
         $artikel->pict = $pict;
     }
     $artikel->save();
     return redirect(url('all_artikel'));
 }
示例#4
0
 public function update($id)
 {
     $Category = Category::find($id);
     $input = Input::all();
     $rules = array('image' => 'image');
     $niceNames = array('image' => 'image');
     $validator = Validator::make($input, $rules);
     $validator->setAttributeNames($niceNames);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]);
     } else {
         if (Input::has('show')) {
             $Category->show = Input::get('show');
         }
         if (Input::has('ordering')) {
             $Category->ordering = Input::get('ordering');
         }
         if (Input::has('status')) {
             $Category->status = Input::get('status');
         }
         if (Input::has('title')) {
             $Category->title = Input::get('title');
         }
         if (Input::has('favor')) {
             $Category->favor = Input::get('favor');
         }
         if (Input::has('level2')) {
             if (Input::get('level2') != '') {
                 $Category->parent_id = Input::get('level2');
             } else {
                 $Category->parent_id = null;
             }
         }
         if (Input::hasfile('image')) {
             $file = Input::file('image');
             $destinationPath = 'uploads/category/';
             $filename = $file->getClientOriginalName();
             Input::file('image')->move($destinationPath, $filename);
             $ext = substr($filename, strrpos($filename, "."));
             $newFileName = basename($filename, $ext) . "_" . $Category->id . "_" . date("Ymdhis") . $ext;
             rename($destinationPath . $filename, $destinationPath . $newFileName);
             Category::where('id', $Category->id)->update(['image_path' => $destinationPath . $newFileName]);
         }
         $Category->save();
         if (Input::hasfile('image')) {
             return Response::json(['success' => true, 'message' => 'Category has been updated!', 'file' => asset($destinationPath . $newFileName)]);
         } else {
             return Response::json(['success' => true, 'message' => 'Category has been updated!']);
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $post = posts::find(Input::get('id'));
     $post->idpengguna = Auth::user()->id;
     $post->judul = Input::get('judul');
     $post->isi = Input::get('isi');
     $post->tag = Input::get('tag');
     $post->slug = str_slug(input::get('judul'));
     if (Input::hasfile('sampul')) {
         $sampul = date("YmdHis") . uniqid() . "." . Input::file('sampul')->getClientOriginalExtension();
         Input::file('sampul')->move(storage_path(), $sampul);
         $post->sampul = $sampul;
     }
     $post->save();
     return redirect(url('artikel'));
 }
示例#6
0
 public function kirimcover()
 {
     $post = new Buku();
     // $post->idpengguna = Auth::user()->id;
     $post->title = Input::get('title');
     $post->description = Input::get('description');
     $post->slug = str_slug(input::get('title'));
     if (Input::hasfile('cover')) {
         $cover = date("YmdHis") . uniqid() . "." . Input::file('cover')->getClientOriginalExtension();
         Input::file('cover')->move(storage_path(), $cover);
         $post->cover = $cover;
     }
     $post->save();
     return redirect(url('cover'));
 }
示例#7
0
 /**
  * Update an existing event's info in the events table.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function updateEvent(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|max:40', 'venue' => 'required|max:30', 'city' => 'required|max:30', 'price' => 'required|numeric', 'information' => 'required|max:255', 'description' => 'required', 'capacity' => 'required|numeric', 'date' => 'required|date', 'image' => 'image']);
     $name = $request->input('name');
     $venue = $request->input('venue');
     $city = $request->input('city');
     $price = $request->input('price');
     $information = $request->input('information');
     $description = $request->input('description');
     $capacity = $request->input('capacity');
     $date = $request->input('date');
     $image = $request->input('image');
     if (Input::hasfile('image')) {
         Event::where('id', $id)->update(['name' => $name, 'venue' => $venue, 'city' => $city, 'price' => $price, 'information' => $information, 'description' => $description, 'capacity' => $capacity, 'date' => $date, 'image' => $image]);
         $imgName = $id . "." . Input::file('image')->getClientOriginalExtension();
         //gets the event ID and concat on the imaage file extension that was uploaded
         Input::file('image')->move(__DIR__ . '/../../../public/img/event_images', $imgName);
         //moves the uploaded image from the tmp directory to a premanant one (/public/img/event_images) and renames it to <eventID>.<fileExt>
         $image = Event::where('id', $id)->first();
         //returns the same event as the one being updated
         $image->image = $imgName;
         //adds the image name from above to the image column of the latest event
         $image->save();
         //saves the above action
     } else {
         Event::where('id', $id)->update(['name' => $name, 'venue' => $venue, 'city' => $city, 'price' => $price, 'information' => $information, 'description' => $description, 'capacity' => $capacity, 'date' => $date]);
     }
     return redirect('admin');
 }