本文整理汇总了PHP中App\Http\Controllers\Auth::hasPerm方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::hasPerm方法的具体用法?PHP Auth::hasPerm怎么用?PHP Auth::hasPerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth
的用法示例。
在下文中一共展示了Auth::hasPerm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(PostRequest $request, $id)
{
$post = App\Post::where('id', $id)->first();
if (!\Auth::hasPerm($post->user_id)) {
\Session::flash('flash_message', 'You do not have permission to edit this post.');
return redirect('thread/' . $this->data['post']->thread_id);
}
$post->post = $request->post;
$post->save();
return redirect('thread/' . $post->thread_id);
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(ProfileRequest $request, $id)
{
$profile = App\User::findOrFail($id)->profile;
if (!\Auth::hasPerm($id)) {
\Session::flash('flash_message', 'You do not have permission to edit this profile.');
return redirect('user/' . $id);
}
if ($request->file('avatar')) {
//get avatar and reference it
$file = \Input::file('avatar');
//filename for resized avatar
$filename = 'av_' . $id . '.' . $file->getClientOriginalExtension();
//image instantiations
$img = \Image::make($file->getRealPath());
//resize image with aspect ratio constraint
$img->resize(150, 150, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
//save in avatar directory
$img->save('img/avatars/' . $filename);
//destroy source
$img->destroy();
//save reference
$profile->avatar = $filename;
}
if ($request->bio) {
$profile->bio = $request->bio;
}
$profile->save();
return redirect('user/' . $id);
}