本文整理汇总了PHP中app\Photo::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::where方法的具体用法?PHP Photo::where怎么用?PHP Photo::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Photo
的用法示例。
在下文中一共展示了Photo::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: isSlugUnique
/**
* Checks to see whether the slug passed is unique
*
* @param $slug
* @return bool
*/
public static function isSlugUnique($slug)
{
if (!Photo::where('slug', '=', $slug)->first()) {
return true;
} else {
return false;
}
}
示例3: handle
/**
* Handle the event.
*
* @param UserWasDeleted $event
* @return void
*/
public function handle(UserWasDeleted $event)
{
// Delete everything the user created
Article::where('user_id', $event->user_id)->delete();
Photo::where('user_id', $event->user_id)->delete();
PhotoAlbum::where('user_id', $event->user_id)->delete();
Video::where('user_id', $event->user_id)->delete();
VideoAlbum::where('user_id', $event->user_id)->delete();
}
示例4: viewReadOnePublic
public function viewReadOnePublic($id)
{
// Set logged in user to a variable.
$authUser = Auth::user();
// Find the user in the database.
$user = User::findOrFail($id);
$photos = Photo::where('user_id', '=', $user->id)->where('private', '=', 0)->latest('id')->paginate(12);
// Return view with variables.
return view('user.viewReadOnePublic')->with('authUser', $authUser)->with('user', $user)->with('photos', $photos);
}
示例5: multiple_upload
public function multiple_upload(Request $request)
{
/*
* Tests incoming files to make sure there's no duplicates in db
*/
// getting all of the post data
$files = Input::file('userfile');
// Making counting of uploaded images
$file_count = count($files);
// start count how many uploaded
$uploadcount = 0;
$hash_type = 'md5';
// don't change this on an existing database!
$filepath = 'img/';
$thumbpath = 'img/thumbs/';
foreach ($files as $file) {
if (in_array(exif_imagetype($file), array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
$filename = $file->getClientOriginalName();
$extension = strtolower($file->getClientOriginalExtension());
$photo = new Photo();
//photo db object
$photo->filename = $filename;
$photo->extension = $extension;
$photo->save();
$currImg = Image::make($file);
$currFilePath = $filepath . $photo->id . "." . $extension;
$currImg->orientate()->save($currFilePath);
// saving the actual file
$hashcheck = hash_file($hash_type, $currFilePath);
$hasDuplicate = Photo::where('hash', $hashcheck)->first();
if ($hasDuplicate) {
// rollback if duplicate found
File::delete($currFilePath);
$photo->delete();
} else {
$currImg->heighten(174)->save($thumbpath . $photo->id . "_thumb" . "." . $extension);
$photo->hash = hash_file($hash_type, $currFilePath);
// hash generated after we save the file
$photo->notes = $request->input('note');
$photo->image_subject = "Rosemary";
$photo->save();
$uploadcount++;
}
$currImg->destroy();
// free up memory
}
}
return $file_count - $uploadcount;
}
示例6: delete
public function delete(PhotoDeleteRequest $request)
{
if (!$request->has('filename')) {
return;
}
$photo = Photo::where('disk_name', $request->get('filename'))->first();
if (Auth::user()->hasRole('admin')) {
$this->deleteFile($photo);
} else {
if ($photo->user_id == Auth::user()->id) {
$this->deleteFile($photo);
}
}
return response()->json(['status', 'ok']);
}
示例7: postChangePhoto
public function postChangePhoto(Request $request, \App\User $user)
{
if ($request->file('user_photo')->isValid()) {
$destinationPath = base_path() . '/public/images/uploads';
$extension = $request->file('user_photo')->getClientOriginalExtension();
$fileName = md5($request->file('user_photo')->getFileName()) . '.' . $extension;
$moved = $request->file('user_photo')->move($destinationPath, $fileName);
if (!$moved) {
return redirect('/')->withMessage('There was a problem uploading your photo.');
}
$photo = \App\Photo::where('user_id', $user->id)->first();
$photo->path = $fileName;
$photo->save();
}
return redirect('/')->withMessage('Your photo has been updated successfully.');
}
示例8: deleteRelatedPhotos
public function deleteRelatedPhotos($id, $model)
{
$model = 'App\\' . $model;
$photos = Photo::where('imageable_type', $model)->where('imageable_id', $id);
if (count($photos) > 0) {
foreach ($photos->get() as $photo) {
$photoPath = public_path('images/uploads/' . $photo->path);
try {
if (File::isFile($photoPath)) {
File::delete($photoPath);
}
} catch (Exception $e) {
}
}
$photos->delete();
}
}
示例9: imageDelete
/**
* delete a file in a model
*
* @param $file
*
* @return bool
*/
public function imageDelete($file)
{
$photo = Photo::where('location', $file)->get()->first();
Helper::allow('album-destroy', $photo->album);
$path = Helper::getImagePath($file);
$photo->delete();
$result = Storage::delete($path);
return response()->json(['files' => $result]);
}
示例10: show
public function show($id)
{
$photo_album = PhotoAlbum::find($id);
$photos = Photo::where('photo_album_id', $id)->get();
return view('photo.view_album', compact('photos', 'photo_album'));
}
示例11: create
function create(Request $request)
{
if (Session::has('user')) {
//Check the type of comment type to determine what id is to be inserted [photo_id, character_id, family_id, specy_id, post_id, mate_id]
$iFromType = Input::get('comment-from-type');
$iFromWhereID = null;
$iCommentPhotoID = 0;
$aComment = [];
switch ($iFromType) {
case Comment::COMMENT_FROM_TYPE_USER:
$iFromWhereID = "user_id";
break;
case Comment::COMMENT_FROM_TYPE_CHARACTER:
$iFromWhereID = "character_id";
break;
case Comment::COMMENT_FROM_TYPE_FAMILY:
$iFromWhereID = "family_id";
break;
case Comment::COMMENT_FROM_TYPE_SPECY:
$iFromWhereID = "specy_id";
break;
case Comment::COMMENT_FROM_TYPE_PHOTO:
$iFromWhereID = "photo_id";
break;
case Comment::COMMENT_FROM_TYPE_POST:
$iFromWhereID = "post_id";
break;
case Comment::COMMENT_FROM_TYPE_MATE:
$iFromWhereID = "mate_id";
break;
}
$oComment = Comment::create(['from_user_id' => Session::get('user')['id'], 'to_user_id' => Input::get('comment-to-user-id'), 'comment_text' => Input::get('comment-text'), 'status' => Comment::COMMENT_STATUS_DEFAULT, 'comment_type' => $request->file('comment-photo') != null ? Comment::COMMENT_TYPE_PHOTO : Comment::COMMENT_TYPE_TEXT, 'comment_from_type' => Input::get('comment-from-type'), $iFromWhereID => Input::get('comment-from-id'), 'comment_photo_id' => $iCommentPhotoID]);
//Check if there's a file
if ($request->file('comment-photo') != null) {
$sInputImageName = str_replace(' ', '_', Input::get('comment-to-user-id') . '_' . $request->file('comment-photo')->getClientOriginalName());
$sImageName = rand(1, 1000000) . '_' . Session::get('user')['id'] . '_' . $sInputImageName;
$request->file('comment-photo')->move(base_path() . '/public/' . Photo::PHOTO_LINK_COMMENT, $sImageName);
$oPhoto = Photo::create(['user_id' => Session::get('user')['id'], 'photo_type' => Photo::PHOTO_TYPE_COMMENT, 'photo_link' => Photo::PHOTO_LINK_COMMENT . $sImageName, 'status' => Photo::PHOTO_STATUS_DEFAULT]);
$iCommentPhotoID = $oPhoto->toArray()['id'];
if ($oPhoto) {
Comment::where('id', $oComment->toArray()['id'])->update(['comment_photo_id' => $iCommentPhotoID]);
}
}
if ($oComment) {
$aComment = Comment::where('id', $oComment->toArray()['id'])->first()->toArray();
$aNotification = Notification::create(['from_user_id' => Session::get('user')['id'], 'to_user_id' => Input::get('comment-to-user-id'), 'notification_type' => Notification::NOTIFICATION_TYPE_COMMENT, 'status' => Notification::NOTIFICATION_STATUS_ACTIVE, 'comment_id' => $aComment['id']]);
Update::create(['user_id' => Session::get('user')['id'], 'update_type' => Update::UPDATE_TYPE_COMMENT, 'comment_id' => $aComment['id'], 'status' => Update::UPDATE_STATUS_ACTIVE]);
//FOR DISPLAY
$aComment['from_user'] = User::where('id', Session::get('user')['id'])->first()->toArray();
$aComment['photo_comment'] = $aComment['comment_photo_id'] > 0 ? Photo::where('id', $aComment['comment_photo_id'])->first()->toArray() : [];
}
$view = view('users.comments.partials.partial-comment-owner')->with('aComment', $aComment);
if ($aComment) {
return response()->json(['status' => true, 'message' => "Successfully submitted comment", 'view' => (string) $view]);
} else {
return response()->json(['status' => false, 'message' => "Something went wrong. Please try again"]);
}
}
}
示例12: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($id)
{
$data['photos'] = Photo::where('album_id', $id)->get();
return view('admin.photos', $data);
}
示例13: deleteExistingPhotos
/**
* Find the related photo on the given Model, If there's an existing
* photo, we will loop through them and then delete them one by one.
* And finally, we will delete it's record from the "photos" table
*/
public function deleteExistingPhotos($id, $model)
{
$model = 'App\\' . $model;
$oldPhoto = Photo::where('imageable_type', $model)->where('imageable_id', $id);
if (count($oldPhoto) > 0) {
foreach ($oldPhoto->get() as $photo) {
$oldPhotoPath = public_path('images/uploads/' . $photo->path);
if (File::isFile($oldPhotoPath)) {
File::delete($oldPhotoPath);
}
}
$oldPhoto->delete();
}
}
示例14: get_name
private function get_name($name)
{
if (Photo::where(['name' => $name])->count()) {
$name = mt_rand(0, 100) . $name;
self::get_name($name);
}
return $name;
}
示例15:
<title>Show All Photos for {{$landmark->name}}</title>
@stop
@section('content')
<div class="container">
<h1>Here are all the photos on the site for:</h1>
<h2>{{$landmark->name}}</h2>
<div class="centered_text">
@if(Auth::check())
<a href='/photos/{{$landmark->id}}/create'>Add a photo</a>
@else
@endif
</div>
<?php
$photos = \App\Photo::where('landmark_id', '=', $landmark->id)->orderBy('id')->get();
?>
@foreach($photos as $photo)
<?php
$user_name = DB::table('users')->where('id', '=', $photo->user_id)->value('name');
?>
<div style="text-align: center" class="user_results_container">
<h2>Photo ID#: {{ $photo->id }}</h2>
<div class="centered_text">Uploaded by {{$user_name}}</div>
<br>
<div class="centered_text">"Description: {{$photo->photo_description}}</div>
<br>
<div class="outer">
<div class="image">
<img style='width:100%' src={{$photo->filepath}}>
</div>