本文整理汇总了PHP中app\Photo::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::findOrFail方法的具体用法?PHP Photo::findOrFail怎么用?PHP Photo::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Photo
的用法示例。
在下文中一共展示了Photo::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($albumId, $id)
{
$photo = Photo::findOrFail($id);
try {
File::delete(public_path() . '/uploads/photos/' . $photo->photo);
$photo->destroy($id);
} catch (Exception $e) {
App::abort(404);
}
return Redirect::route('admin.photos.show', $albumId);
}
示例3: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create($id)
{
$photo = Photo::findOrFail($id);
$photoSrc = '/photo_files/normal/' . $photo->file_name;
$photoId = $photo->id;
$galleryList = array();
$galleries = Gallery::orderBy('name', 'asc')->get();
foreach ($galleries as $gallery) {
$galleryList[strval($gallery->id)] = $gallery->name;
}
return view('submissions.create')->with(['photoSrc' => $photoSrc, 'photoId' => $photoId, 'galleryList' => $galleryList, 'galleryId' => null]);
}
示例4: actionCreate
public function actionCreate(Requests\CreateLikeRequest $request)
{
// Create a new model instance and populate it with the request.
$like = new Like($request->all());
// Find in the database the photo sent with the request.
$photo = Photo::findOrFail($request->input('photo_id'));
// Attach the like to the photo.
$like = $photo->likes()->save($like);
// Save the like in the database.
Auth::user()->likes()->save($like);
// Redirect.
return redirect('/photos');
}
示例5: actionCreate
public function actionCreate(Requests\CreateCommentRequest $request)
{
// Create a new model instance and populate it with the request.
$comment = new Comment($request->all());
// Find in the database the photo sent with the request.
$photo = Photo::findOrFail($request->input('photo_id'));
// Attach the comment to the photo.
$comment = $photo->comments()->save($comment);
// Save the comment in the database.
Auth::user()->comments()->save($comment);
// Redirect with flash message.
\Session::flash('flash_message', 'You have successfully commented on a photo.');
return json_encode($comment);
}
示例6: handle
public function handle(Request $request, Closure $next, $param)
{
if ($request->user()->is_admin == 0) {
if ($param == 'album') {
$access = $request->user()->hasAccess($request->id);
} else {
$photo = Photo::findOrFail($request->id);
$access = $request->user()->hasAccess($photo->album_id);
}
if (!$access) {
return new Response('You do not have access to this album or photo', 403);
}
}
return $next($request);
}
示例7: viewUpdate
public function viewUpdate($id)
{
// Set logged in user to a variable.
$authUser = Auth::user();
// Find photo in database.
$photo = Photo::findOrFail($id);
// Find the photo's user in database, set to variable.
$userId = $photo->user_id;
$user = User::findOrFail($userId);
// If logged in user does not own photo, return error.
if ($authUser->id !== $user->id) {
return view('errors.403');
}
// Find all tags in database.
$tags = Tag::all();
// Return view with variables.
return view('photos.viewUpdate')->with('photo', $photo)->with('tags', $tags)->with('authUser', $authUser);
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$photo = Photo::findOrFail($id)->delete();
return back();
}
示例9: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
/*
* Find the photo we want to edit
*/
$photo = Photo::findOrFail($id);
return view('dashboard.photos.edit', ['photo' => $photo]);
}
示例10: destory
public function destory($id)
{
Photo::findOrFail($id)->delete();
return back();
}
示例11: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//$file_path = '/var/www/html/storage';
$file_path = 'storage/';
$photo = Photo::findOrFail($id);
if (\Auth::user() == $photo->user) {
unlink($file_path . '/thumbnail_l/' . $photo->filename);
unlink($file_path . '/thumbnail_s/' . $photo->filename);
unlink($file_path . '/photo/' . $photo->filename);
$photo->delete();
} else {
abort(403, 'Unauthorized action.');
}
return back();
}
示例12: destroy
public function destroy($id)
{
Photo::findOrFail($id)->delete();
return redirect()->back();
}
示例13: destroy
public function destroy($id)
{
/** @noinspection PhpUndefinedMethodInspection */
Photo::findOrFail($id)->delete();
return redirect()->back();
}
示例14: destroyPhoto
public function destroyPhoto($id)
{
Photo::findOrFail($id)->delete;
return view('flyers.show', compact('flyer'));
}
示例15: destroy
/**
* Remove the specified Photo
*
* @param $zip
* @param $street
* @param AddPhotoRequest|Request $request
* @return \Illuminate\Http\Response
*/
public function destroy($id, AddPhotoRequest $request)
{
Photo::findOrFail($id)->delete();
return back();
}