当前位置: 首页>>代码示例>>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;未经允许,请勿转载。