當前位置: 首頁>>代碼示例>>PHP>>正文


PHP app\Photo類代碼示例

本文整理匯總了PHP中app\Photo的典型用法代碼示例。如果您正苦於以下問題:PHP Photo類的具體用法?PHP Photo怎麽用?PHP Photo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Photo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: updateAlbum

 public function updateAlbum(Request $request)
 {
     $albums = json_decode($request->all()['albums'], true);
     $len = count($albums);
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Album::truncate();
     Photo::truncate();
     Album::reindex();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     foreach ($albums as $a) {
         $album = new Album();
         $album->album_id = $a['id'];
         $album->name = $a['name'];
         $album->created_time = $a['created_time'];
         $album->save();
         $photos = $a['photos']['data'];
         foreach ($photos as $p) {
             $photo = new Photo();
             $photo->album_id = $album->id;
             $photo->photo_id = $p['id'];
             $photo->source = $p['source'];
             $photo->save();
         }
     }
     return '1';
 }
開發者ID:jentleyow,項目名稱:pcf,代碼行數:26,代碼來源:AlbumsController.php

示例2: destroy

 public function destroy($year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $photo = new Photo($date);
     if ($photo->exists() === false) {
         abort(404);
     }
     $photo->delete();
     return response()->json($photo);
 }
開發者ID:simondubois,項目名稱:photos,代碼行數:10,代碼來源:PhotoController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $packages = Package::all();
     foreach ($packages as $package) {
         $filename = sprintf('%s-Tour.jpg', str_replace(' ', '-', $package->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $package->id;
         $newPhoto->imageable_type = 'App\\Package';
         $newPhoto->save();
     }
 }
開發者ID:marktimbol,項目名稱:eclipse,代碼行數:17,代碼來源:PackagePhotoTableSeeder.php

示例4: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $categories = Category::all();
     foreach ($categories as $category) {
         $filename = sprintf('%s-Tour.jpg', str_replace([' ', '/'], '-', $category->name));
         $newPhoto = new Photo();
         $newPhoto->path = $filename;
         $newPhoto->imageable_id = $category->id;
         $newPhoto->imageable_type = 'App\\Category';
         $newPhoto->save();
     }
 }
開發者ID:marktimbol,項目名稱:eclipse,代碼行數:17,代碼來源:CategoryPhotoTableSeeder.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //Here we will ceate a new object of model file called
     $photo = new Photo();
     $photo->name = $request->name;
     //$photo->path = $request->file("photoFile");
     $photo->user_id = $request->user_id;
     //I need to copy the file a give it some valid name
     $photo->path = "Photo" . $photo->user_id . ".png";
     $request->file("photoFile")->move(storage_path() . "/" . $photo->path);
     $photo->save();
     return redirect('/photo');
 }
開發者ID:RahulVerlekar,項目名稱:PhotoGrab,代碼行數:19,代碼來源:PhotoController.php

示例6: index

 public function index($format, $year, $month, $day)
 {
     $date = $this->createDate($year, $month, $day);
     $photo = new Photo($date);
     if ($photo->exists() === false) {
         abort(404);
     }
     if (array_key_exists($format, $photo->maxSizes) === false) {
         abort(400);
     }
     $filePath = $photo->getPath($format, true);
     return response()->download($filePath, $photo->getDownloadName());
 }
開發者ID:simondubois,項目名稱:photos,代碼行數:13,代碼來源:PhotoController.php

示例7: uploadPhotos

 public function uploadPhotos(Request $request)
 {
     //adding image during image intervention
     $image = Input::file('image');
     $filename = time() . '-' . $image->getClientOriginalName();
     $path = $image->move('images\\photos', $filename);
     // Image::make($image->getRealPath())->resize('600','400')->save($path);
     $photo = new Photo();
     $photo->photo_name = $filename;
     $photo->album_id = $request->input('album_id');
     $photo->save();
     return redirect('profile');
 }
開發者ID:vikashkrkashyap,項目名稱:photographic-website,代碼行數:13,代碼來源:AlbumController.php

示例8: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $photoDirectory = env('BH_PHOTO_DIRECTORY');
     $fileExtension = $this->file->getClientOriginalExtension();
     $fileName = str_random(10) . '.' . $fileExtension;
     $image = \Image::make($this->file->getRealPath());
     $image->resize(800, 800);
     $image->save($photoDirectory . '/photo_files/normal/' . $fileName);
     $image->resize(100, 100);
     $image->save($photoDirectory . '/photo_files/thumbnail/' . $fileName);
     $photo = new Photo();
     $photo->file_name = $fileName;
     $photo->save();
 }
開發者ID:BobHumphrey,項目名稱:tumblr-photos,代碼行數:19,代碼來源:SavePhoto.php

示例9: imageUpload

 public function imageUpload(Request $request)
 {
     $rules = ['image' => 'required|image|mimes:jpeg'];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect('galerija')->withErrors($validator);
     } else {
         $name1 = str_random(6) . '.jpg';
         $request->file('image')->move('images/web/', $name1);
         $photo = new Photo();
         $photo->name = 'images/web/' . $name1;
         $photo->save();
         return redirect('galerija');
     }
 }
開發者ID:LinaSakarne,項目名稱:teikasmuzikanti,代碼行數:15,代碼來源:PhotoController.php

示例10: addPhoto

 public function addPhoto($zip, $street, Request $request)
 {
     $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']);
     $photo = Photo::fromForm($request->file('photo'));
     Flyer::locatedAt($zip, $street)->addPhoto($photo);
     //return view('flyers.show',compact('flyer'));
 }
開發者ID:sonfordson,項目名稱:Project-Flyer,代碼行數:7,代碼來源:FlyersController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param StorePhotoRequest $request
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function store(StorePhotoRequest $request)
 {
     //TODO
     // Find a safe way to getClientOriginalExtension()
     //Construct file and path info
     $file = $request->file('photo');
     $ext = '.' . $file->getClientOriginalExtension();
     $filename = time() . $ext;
     $basePath = '/uploads/img/' . $filename;
     $thumbPath = '/uploads/img/thumb/' . $filename;
     $localPath = public_path() . $basePath;
     $localThumbPath = public_path() . $thumbPath;
     //DB info
     $mimeType = $file->getClientMimeType();
     $slug = Photo::generateUniqueSlug(8);
     //Save the full image and the thumb to the server
     $imageFull = Image::make($file->getRealPath())->save($localPath);
     $imageThumb = Image::make($file->getRealPath())->widen(400)->save($localThumbPath);
     //Create the DB entry
     $imageStore = Photo::create(['path' => $basePath, 'thumb_path' => $thumbPath, 'mime_type' => $mimeType, 'slug' => $slug]);
     if ($request->ajax()) {
         return response()->json($imageStore);
     } else {
         return redirect()->route('home')->with(['global-message' => 'Uploaded!', 'message-type' => 'flash-success']);
     }
 }
開發者ID:DefrostedTuna,項目名稱:php-image,代碼行數:32,代碼來源:PhotoController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param OrganisationRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(OrganisationRequest $request)
 {
     /**
      * If Photo is present then
      */
     if ($request->hasFile('photo')) {
         if ($request->file('photo')->isValid()) {
             $photoName = md5(Carbon::now()) . "." . $request->file('photo')->getClientOriginalExtension();
             $request->file('photo')->move(public_path('images'), $photoName);
             $photo = Photo::create(['url' => $photoName]);
             $photoId = $photo->id;
         } else {
             return back()->withNotification('Error! Photo Invalid!')->withType('danger');
         }
     } else {
         $photoId = null;
     }
     $slug = slug_for_url($request->name);
     $details = empty($request->details) ? null : $request->details;
     $initials = empty($request->initials) ? null : $request->initials;
     $address = empty($request->address) ? null : $request->address;
     if (Auth::check()) {
         $request->user()->organisations()->create(['name' => $request->name, 'initials' => $initials, 'details' => $details, 'address' => $address, 'photo_id' => $photoId, 'slug' => $slug, 'user_ip' => $request->getClientIp()]);
     } else {
         $user = User::findOrFail(1);
         $user->organisations()->create(['name' => $request->name, 'initials' => $initials, 'details' => $details, 'address' => $address, 'photo_id' => $photoId, 'slug' => $slug, 'user_ip' => $request->getClientIp()]);
     }
     return back()->withNotification('Organisation has been added!')->withType('success');
 }
開發者ID:kinnngg-lenz,項目名稱:csacerc,代碼行數:35,代碼來源:OrganisationsController.php

示例13: test_a_photo_has_a_path

 /**
  * A basic test example.
  *
  * @return void
  */
 public function test_a_photo_has_a_path()
 {
     $photo = Photo::create(['path' => '/storage/test.png']);
     $photo = Photo::find(1);
     $path = $photo->path;
     $this->assertequals("/storage/test.png", $path);
 }
開發者ID:ynniswitrin,項目名稱:8A-Fotos,代碼行數:12,代碼來源:PhotoTest.php

示例14: run

 /**
  *
  */
 public function run()
 {
     $faker = Faker::create('en_US');
     /*
      * Base User Accounts
      */
     // Mike's account
     $michael = User::create(['name' => 'Michael Norris', 'email' => 'mstnorris@gmail.com', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     //$michaelProfile = Profile::create([
     //    'user_id'    => $michael->id,
     //    'nick_name'  => 'Mike',
     //    'photo_url'  => 'https://placeholdit.imgix.net/~text?txt=Mike&txtsize=80&bg=eceff1&txtclr=607d8b&w=640&h=640', //'/profile_photos/mike.jpg',
     //    'created_at' => Carbon::now(),
     //    'updated_at' => Carbon::now()
     //]);
     //
     //$michael->profile()->save($michaelProfile);
     unset($photos);
     $photos = [];
     foreach (range(1, 20) as $index) {
         $photos[] = ['id' => Uuid::generate(4), 'path' => $index . '.jpeg'];
         //echo $photos[$index + 1] . "\r\n";
     }
     Photo::insert($photos);
 }
開發者ID:mstnorris,項目名稱:gallery.michaelnorris.co.uk,代碼行數:28,代碼來源:ConstantsTableSeeder.php

示例15: register

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $attributes = $request->only(array('username', 'first_name', 'last_name', 'description', 'email', 'tel_no', 'type', 'password'));
     // Create user.
     $user = $this->create($attributes);
     if ($request->file('image')) {
         //make timestamp and append username for filename
         $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
         $imageFile = Input::file('image');
         $mime = "." . substr($imageFile->getMimeType(), 6);
         //move file to /public/images/
         $filename = $timestamp . '-' . $user->username;
         $photoData = array('fileName' => $filename, 'mime' => $mime);
         $photo = Photo::create($photoData);
         $imageFile->move(public_path() . '/images/uploads/', $filename . $mime);
         //associate the image with the user
         $user->photo_id = $photo->id;
         $user->photo()->associate($photo);
     }
     $user->save();
     // Send confirmation link.
     return $this->sendConfirmationLink($user);
 }
開發者ID:getacked,項目名稱:project,代碼行數:33,代碼來源:RegistersUsers.php


注:本文中的app\Photo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。