コード例 #1
0
 public function postAdd()
 {
     $rules = array('album_id' => 'required|numeric|exists:albums,id', 'image' => 'required|mimes:jpeg,bmp,png');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('add_image', array('id' => Input::get('album_id')))->withErrors($validator)->withInput();
     }
     $file = Input::file('image');
     $random_name = str_random(8);
     $destinationPath = 'albums/';
     $extension = $file->getClientOriginalExtension();
     $filename = $random_name . '_album_image.' . $extension;
     $uploadSuccess = Input::file('image')->move($destinationPath, $filename);
     Images::create(array('description' => Input::get('description'), 'image' => $filename, 'album_id' => Input::get('album_id')));
     return Redirect::route('show_album', array('id' => Input::get('album_id')));
 }
コード例 #2
0
ファイル: Images.php プロジェクト: timurAbl93/site
 public static function createImages($image)
 {
     Images::create(['image' => $image->getClientOriginalName()]);
     $image->move('images/slider', $image->getClientOriginalName());
 }
コード例 #3
0
ファイル: Front.php プロジェクト: Bmax-Tech/SEP-Prototype_MVC
 public function add_doctor_save(Request $request)
 {
     $time_stamp = time();
     try {
         /* First -> Create Users Record */
         User::create(['name' => Input::get('first_name'), 'email' => $time_stamp, 'password' => md5($time_stamp), 'mode' => 1]);
         $user = User::whereEmail($time_stamp)->wherePassword(md5($time_stamp))->first();
         /* Second -> Images Record */
         Images::create(['user_id' => $user->id, 'image_path' => 'profile_images/default_user_icon.png']);
         /* Third -> Doctor Object Is Created */
         Doctors::create(['user_id' => $user->id, 'doc_type' => 'NON_FORMAL', 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'gender' => Input::get('gender'), 'dob' => '-', 'nic' => '-', 'address_1' => Input::get('address_1'), 'address_2' => Input::get('address_2'), 'city' => Input::get('city'), 'district' => Input::get('district'), 'contact_number' => Input::get('contact_number'), 'email' => Input::get('email'), 'description' => Input::get('doc_description'), 'rating' => 0, 'tot_stars' => 0, 'rated_tot_users' => 0, 'reg_date' => new \DateTime(), 'longitude' => '0', 'latitude' => '0']);
         $doc_ob = Doctors::whereUser_id($user->id)->first();
         /* Fourth -> add Non Formal Doctors */
         $user_cookie = json_decode($_COOKIE['user'], true);
         Non_Formal_doctors::create(['doctor_id' => $doc_ob->id, 'suggested_user' => $user_cookie[0]['id']]);
         /* Fifth -> Create Specialization */
         Specialization::create(['doc_id' => $doc_ob->id, 'spec_1' => Input::get('specialized')[0], 'spec_2' => Input::get('specialized')[1], 'spec_3' => Input::get('specialized')[2], 'spec_4' => Input::get('specialized')[3], 'spec_5' => Input::get('specialized')[4]]);
         /* Sixth -> Create Treatments */
         Treatments::create(['doc_id' => $doc_ob->id, 'treat_1' => Input::get('treatments')[0], 'treat_2' => Input::get('treatments')[1], 'treat_3' => Input::get('treatments')[2], 'treat_4' => Input::get('treatments')[3], 'treat_5' => Input::get('treatments')[4]]);
         /* Seventh -> Create Consultation Times */
         ConsultationTimes::create(['doc_id' => $doc_ob->id, 'time_1' => '-', 'time_2' => '-', 'time_3' => '-']);
     } catch (Exception $e) {
         $this->LogError('Non Formal Doctor Create Function', $e);
     }
     $res['CHECK'] = "SUCCESS";
     /* Return Json Type Object */
     return response()->json($res);
 }
コード例 #4
0
 public function uploadimages(\Request $request)
 {
     // Images destination
     $img_dir = "uploads/images";
     $img_thumb_dir = $img_dir . "/thumbs/";
     // create an image manager instance with favored driver
     $manager = new ImageManager(array('driver' => 'imagick'));
     // Create folders if they don't exist
     if (!file_exists($img_dir)) {
         mkdir($img_dir, 0777, true);
     }
     // Create Thumbnail folders if they don't exist
     if (!file_exists($img_thumb_dir)) {
         mkdir($img_thumb_dir, 0777, true);
     }
     $img = Request::file('file');
     $input = Request::all();
     $imagedata = array();
     // Upload the image in the correct destination
     $userDate = Auth::user();
     $filename = md5(microtime() . $img->getClientOriginalName()) . "." . $img->getClientOriginalExtension();
     $upload_success = $img->move($img_dir, $filename);
     // create new Intervention Image
     Image::make($img_dir . "/" . $filename)->resize(200, 200)->save($img_thumb_dir . $filename);
     // create new Intervention Image
     $imagedata['name'] = $filename;
     $imagedata['url'] = url() . '/uploads/images/' . $filename;
     $imagedata['thumb_url'] = $img_thumb_dir . $filename;
     $imagedata['size'] = $filename;
     $imagedata['title'] = $input['filetitle'];
     $imagedata['status'] = $input['filestatus'];
     $imagedata['album_id'] = $input['album_id'];
     $imagedata['user_id'] = $userDate->id;
     // exit( var_dump($imagedata));
     $user = Images::create($imagedata);
     $filedata['name'] = $filename;
     $filedata['url'] = url() . '/uploads/images/' . $filename;
     $filedata['thumbnailUrl'] = url() . '/uploads/images/' . $filename;
     $filedata['deleteType'] = "GET";
     $filedata['deleteUrl'] = url() . "/images/destroy/" . $user->id;
     $channels[] = $filedata;
     $response = Response::json(array("files" => $channels));
     return $response;
 }
コード例 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $product = Product::find($id);
     $this->validate($request, ['title' => 'required|max:255', 'description' => 'required', 'price' => 'integer|between:0,30000']);
     $title = Input::get('title');
     $description = Input::get('description');
     $price = Input::get('price');
     $oldPhotos = Input::get('oldPhotos');
     $colors = Input::get('color');
     $categories = Input::get('categories');
     $product->update(['title' => $title, 'description' => $description, 'price' => $price]);
     $images = Input::file('photos');
     $colors = Input::get('color');
     $photos = [];
     $photos_ids = [];
     if ((is_array($images) || is_object($images)) && !($images[0] == null)) {
         for ($i = 0; $i < sizeof($images); $i++) {
             //dd($images);
             $image = $images[$i];
             $color = $colors[$i];
             srand(time());
             $filename = rand() . $i . '.' . $image->getClientOriginalExtension();
             //save image
             Images::create(['color' => $color, 'img' => $filename, 'alt' => '123']);
             $path = storage_path() . '/app/images/' . $filename;
             $im = Image::make($image->getRealPath());
             if ($im->width() > 900) {
                 $im->resize(900, null, function ($c) {
                     $c->aspectRatio();
                     $c->upsize();
                 });
             }
             $im->save($path);
             $p = Images::where('img', $filename)->first();
             array_push($photos, $p);
             array_push($photos_ids, $photos[$i]->id);
         }
     }
     if (isset($categories)) {
         $product->category()->sync($categories);
     }
     if (is_array($oldPhotos) && !is_array($photos_ids)) {
         $allPhotos = $oldPhotos;
         $product->images()->sync($allPhotos);
     }
     if (is_array($photos_ids) && !is_array($oldPhotos)) {
         $allPhotos = $photos_ids;
         $product->images()->sync($allPhotos);
     }
     if (is_array($photos_ids) && is_array($oldPhotos)) {
         $allPhotos = array_merge($photos_ids, $oldPhotos);
         $product->images()->sync($allPhotos);
     }
     return redirect()->back()->with('message', ' პროდუქტი განხლდა');
 }
コード例 #6
0
 public function uploadImage($id, Request $request)
 {
     if ($request->hasFile('file')) {
         $trap = Traps::findOrFail($id);
         $user_id = Traps::findOrFail($trap->id);
         $unique_id = uniqid() . '_' . uniqid();
         $imageName = $unique_id . '.' . $request->file('file')->getClientOriginalExtension();
         $request->file('file')->move(base_path() . '/public/uploads/images/' . $user_id->user_id . '/', $imageName);
         $image['plate_number'] = $trap->plate_counter;
         $image['unique_id'] = $unique_id;
         $image['image'] = $imageName;
         $image['trap_id'] = $id;
         $i = Images::create($image);
         return redirect(route('image', $i->id));
     } else {
         return Redirect::back()->withInput()->withErrors('Morate unijeti file za oglas');
     }
 }