本文整理汇总了PHP中app\Image::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::findOrFail方法的具体用法?PHP Image::findOrFail怎么用?PHP Image::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Image
的用法示例。
在下文中一共展示了Image::findOrFail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$image = Image::findOrFail($id);
$image->delete();
flash()->warning('Gambar telah dihapus!');
return redirect('/dashboard/images');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return Response
*/
public function update($id, Request $request)
{
$this->validate($request, ['original_name' => 'required', 'filename' => 'required']);
$image = Image::findOrFail($id);
$image->update($request->all());
Session::flash('flash_message', 'Image updated!');
return redirect('admin/image');
}
示例3: saveImageAlt
private static function saveImageAlt($image_id, $alt)
{
if (empty($alt)) {
return;
}
$Image = \App\Image::findOrFail($image_id);
$Image->imgalt = $alt;
$Image->save();
return;
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
if (Gate::denies('admin')) {
abort(403);
}
$image = Image::findOrFail($id);
ImageRelease::where('image_id', $id)->delete();
ImageTrack::where('image_id', $id)->delete();
ArtistImage::where('image_id', $id)->delete();
if (Storage::disk('images')->has($image->path)) {
Storage::disk('images')->delete($image->path);
}
$image->delete();
return redirect()->route('home.index')->with('alert-success', [trans('htmusic.deleted')]);
}
示例5: destroy
public function destroy($id)
{
Image::findOrFail($id)->delete();
session()->flash('flash_message', 'Photo Deleted');
return redirect('/gallery');
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Image::findOrFail($id)->delete();
return trans('images.removed');
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$img = Image::findOrFail($id);
// base path
$base_path = public_path() . "/images/";
// remove from file system
// remove thumb
unlink($base_path . "thumbs/{$img->path}");
// remove image
unlink($base_path . "{$img->path}");
// remove from database
$img->delete();
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$image = Image::findOrFail($id);
$image->delete();
Session::flash('flash_message', 'Image successfully deleted!');
return redirect()->route('images.index');
}
示例9: postChange
public function postChange(Request $request)
{
$input = $request->all();
$image = Image::findOrFail($input['id']);
$file = Input::file('images');
$rules = array('file' => 'image|max:3000');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
Session::flash('flash_message', 'Ошибка записи файлов!');
return redirect()->back();
} else {
$destinationPath = 'uploads/images/';
$filename = str_random(15) . '_' . substr($file->getClientOriginalName(), 0, strpos($file->getClientOriginalName(), ".")) . '.' . $file->getClientOriginalExtension();
$upload_success = $file->move($destinationPath, $filename);
$image->path = $destinationPath . $filename;
$image->save();
unlink($input['path']);
Session::flash('flash_message', 'Картинка успешно изменена!');
}
return redirect()->back();
}
示例10: findOrFail
public function findOrFail($id)
{
return Image::findOrFail($id);
}