本文整理汇总了PHP中App\Http\Requests\Auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user方法的具体用法?PHP Auth::user怎么用?PHP Auth::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Requests\Auth
的用法示例。
在下文中一共展示了Auth::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (Auth::check() && Auth::user()->hasAccess('create_paper')) {
return true;
}
return false;
}
示例2: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (\Auth::user()->isModerator()) {
return true;
}
return false;
}
示例3: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$id = $this->route('id');
if ($id == 0) {
return TRUE;
}
return \Auth::user()->owns(\App\AmazonProduct::find($id));
}
示例4: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (\Auth::user()->level->id == 1) {
return true;
} else {
return false;
}
}
示例5: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$profile = $this->route('profiles');
if (!is_null($user = \Auth::user())) {
return $user->is_admin || !is_null($user->profile) && $user->profile->id == $profile;
}
return false;
}
示例6: validator
/**
* Check when user updates details, that if email has changed it is not taken by another user.
*/
public function validator()
{
$validator = Validator::make($this->input(), $this->rules(), $this->messages());
$validator->sometimes('email', 'unique:users', function ($input) {
return $input->email != \Auth::user()->email;
});
return $validator;
}
示例7: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$user = \Auth::user();
if ($user->hasRoles(['admin', 'super admin'])) {
return true;
} else {
return false;
}
}
示例8: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$user = Auth::user();
$group_id = $this->route('group');
// Есть ли права на запись
// является ли пользователь админом
// и админ ли он этой группы
return $user->is_admin && GroupAdmin::where('admin_id', $user->id)->where('group_id', $group_id)->exists();
}
示例9: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$reportId = $this->route('id');
$report = ExpenseReport::find($reportId);
if ($report->owner_id == \Auth::user()->id) {
return true;
}
return false;
}
示例10: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$reportId = $this->route('id');
$report = ExpenseReport::findOrFail($reportId);
if ($report->users()->get(['id'])->contains(\Auth::user()->id) || $report->owner_id == \Auth::user()->id) {
return true;
}
return false;
}
示例11: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (isset(\Auth::user()->site_id)) {
$sites_ids = SiteLanguages::site_access()->select(\DB::raw(' GROUP_CONCAT(id) as sites_ids'))->groupBy('sites_id')->get();
$site_access = 'in:' . $sites_ids[0]->sites_ids;
} else {
$site_access = '';
}
return ['sitelanguages_id' => 'required|' . $site_access, 'title' => 'required|unique:topmenus,title,' . $this->topmenus, 'link' => 'required'];
}
示例12: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (isset(\Auth::user()->site_id)) {
$sites_ids = SiteLanguages::site_access()->select(\DB::raw(' GROUP_CONCAT(id) as sites_ids'))->groupBy('sites_id')->get();
$site_access = 'in:' . $sites_ids[0]->sites_ids;
} else {
$site_access = '';
}
return ['title' => 'required', 'slug' => 'required', 'text' => 'required', 'sitelanguages_id' => 'required|' . $site_access, 'meta_keywords' => 'required', 'meta_description' => 'required'];
}
示例13: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$id = $this->route('id');
if ($id == 0) {
return TRUE;
}
$transactionItem = \App\TransactionItem::find($id);
if (!$transactionItem) {
return TRUE;
}
return \Auth::user()->owns($transactionItem->transaction->customer);
}
示例14: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
switch ($this->method()) {
case 'GET':
case 'DELETE':
return \Auth::user()->can('destroy home') ? true : null;
case 'POST':
return \Auth::user()->can('store home') ? true : null;
case 'PUT':
case 'PATCH':
return \Auth::user()->can('update home') ? true : null;
default:
break;
}
}
示例15: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
/**
* check security in frontend site language for any users
*
* @return string
*/
if (isset(\Auth::user()->site_id)) {
$sites_ids = SiteLanguages::site_access()->select(\DB::raw(' GROUP_CONCAT(id) as sites_ids'))->groupBy('sites_id')->get();
$site_access = 'in:' . $sites_ids[0]->sites_ids;
} else {
$site_access = '';
}
return ['sitelanguages_id' => 'required|' . $site_access, 'slug' => 'required|unique:news,slug', 'text' => 'required', 'meta_keywords' => 'required'];
}