本文整理汇总了PHP中app\Photo类的典型用法代码示例。如果您正苦于以下问题:PHP Photo类的具体用法?PHP Photo怎么用?PHP Photo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Photo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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' => '[email protected]', '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
示例16: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
if ($this->newOnly) {
$photosQueryBuilder = Photo::where('posted_date', '=', '0000-00-00');
} else {
$photosQueryBuilder = Photo::where('id', '>', 0);
}
$photos = $photosQueryBuilder->get();
$gridColumns = [(new FieldConfig('id'))->setLabel('Actions')->setSortable(true)->setCallback(function ($val, EloquentDataRow $row) {
$rowData = $row->getSrc();
$iconShow = '<span class="fa fa-eye"></span> ';
$hrefShow = action('PhotosController@show', [$val]);
$iconUpdate = '<span class="fa fa-pencil"></span> ';
$hrefUpdate = action('PhotosController@edit', [$val]);
$iconDelete = '<span class="fa fa-times"></span> ';
$hrefDelete = action('PhotosController@delete', [$val]);
$iconTumblr = '<span class="fa fa-tumblr-square"></span> ';
$hrefTumblr = $rowData->url;
return '<a href="' . $hrefShow . '">' . $iconShow . '</a> ' . '<a href="' . $hrefUpdate . '">' . $iconUpdate . '</a> ' . '<a href="' . $hrefDelete . '">' . $iconDelete . '</a> ' . '<a href="' . $hrefTumblr . '" target="_blank">' . $iconTumblr . '</a>';
}), (new FieldConfig('file_name'))->setLabel('Photo')->setCallback(function ($val, EloquentDataRow $row) {
$rowData = $row->getSrc();
$image = '<img src="/photo_files/thumbnail/' . $val . '" />';
$hrefShow = action('PhotosController@show', [$rowData->id]);
return '<a href="' . $hrefShow . '">' . $image . '</a>';
}), (new FieldConfig('posted_date'))->setSortable(true)->setSorting(Grid::SORT_DESC), (new FieldConfig('notes'))->setSortable(true), (new FieldConfig('notes_last30'))->setSortable(true)->setLabel('Last 30 Days'), (new FieldConfig('notes_last10'))->setSortable(true)->setLabel('Last 10 Days')];
$gridCfg = (new GridConfig())->setDataProvider(new EloquentDataProvider($photosQueryBuilder))->setColumns($gridColumns);
$grid = new Grid($gridCfg);
return array('narrowGrid' => null, 'grid' => $grid);
}
开发者ID:BobHumphrey,项目名称:tumblr-photos,代码行数:34,代码来源:CreatePhotoGrid.php
示例17: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$recordsPerPage = 3;
$offset = ($this->page - 1) * $recordsPerPage;
$count = Photo::count();
if ($this->page > 1) {
$previousPage = $this->page - 1;
} else {
$previousPage = null;
}
if ($this->page * $recordsPerPage < $count) {
$nextPage = $this->page + 1;
} else {
$nextPage = null;
}
$photos = Photo::orderBy('posted_date', 'desc')->skip($offset)->take($recordsPerPage)->get();
//$previousUrl = action('PhotosController@index', ['page' => $previousPage]);
//$nextUrl = action('PhotosController@index', ['page' => $nextPage]);
if ($previousPage) {
$previousUrl = url('photos/display/' . $previousPage);
} else {
$previousUrl = null;
}
if ($nextPage) {
$nextUrl = url('photos/display/' . $nextPage);
} else {
$nextUrl = null;
}
return ['photos' => $photos, 'previousUrl' => $previousUrl, 'nextUrl' => $nextUrl];
}
开发者ID:BobHumphrey,项目名称:tumblr-photos,代码行数:35,代码来源:CreatePhotosPager.php
示例18: generateUniqueSlug
/**
* Generates a random string and then checks the database to see if it is unique.
*
* @param $number
* @return string
*/
public static function generateUniqueSlug($number)
{
do {
$slug = str_random($number);
} while (!Photo::isSlugUnique($slug));
//While slug is not unique
return $slug;
}
开发者ID:DefrostedTuna,项目名称:php-image,代码行数:14,代码来源:Photo.php
示例19: index
public function index()
{
$news = $this->news->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
$sliders = Photo::join('photo_album', 'photo_album.id', '=', 'photo.photo_album_id')->where('photo.slider', 1)->orderBy('photo.position', 'DESC')->orderBy('photo.created_at', 'DESC')->select('photo.filename', 'photo.name', 'photo.description', 'photo_album.folderid')->get();
$photoalbums = PhotoAlbum::select(array('photo_album.id', 'photo_album.name', 'photo_album.description', 'photo_album.folderid', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photo WHERE ' . DB::getTablePrefix() . 'photo.photo_album_id=' . DB::getTablePrefix() . 'photo_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
$videoalbums = VideoAlbum::select(array('video_album.id', 'video_album.name', 'video_album.description', 'video_album.folderid', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video as v WHERE album_cover=TRUE and v.video_album_id=' . DB::getTablePrefix() . 'video_album.id) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'video WHERE ' . DB::getTablePrefix() . 'video.video_album_id=' . DB::getTablePrefix() . 'video_album.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
return view('site.home.index', compact('news', 'sliders', 'videoalbums', 'photoalbums'));
}
开发者ID:ryleto,项目名称:nightjar,代码行数:8,代码来源:HomeController.php
示例20: delete
public function delete(Request $request, $id)
{
$photo = Photo::findOrFail($id);
$photo->removeThumbnail();
unlink($photo->path);
$albumId = $photo->album_id;
$photo->delete();
return redirect('/album/' . $albumId);
}
开发者ID:pitchinnate,项目名称:photoshare,代码行数:9,代码来源:PhotoController.php
注:本文中的app\Photo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论