本文整理匯總了PHP中app\Photo::generateUniqueSlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP Photo::generateUniqueSlug方法的具體用法?PHP Photo::generateUniqueSlug怎麽用?PHP Photo::generateUniqueSlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Photo
的用法示例。
在下文中一共展示了Photo::generateUniqueSlug方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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']);
}
}