本文整理汇总了PHP中app\User::isAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isAdmin方法的具体用法?PHP User::isAdmin怎么用?PHP User::isAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::isAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
if ($this->user->isAdmin()) {
session()->flash('error', 'Admin cannot create new application.');
return redirect()->route('application');
}
return view('app.form');
}
示例2: handle
/**
* Handle the event.
*
* @param Events $event
* @return void
*/
public function handle(User $user, $remember)
{
if ($user->isAdmin()) {
$this->users->saveLog($user);
}
$this->users->updateLog($user);
}
示例3: edit
public function edit(User $user, Alumini $alumini)
{
if ($user->isAdmin()) {
return true;
}
return $user->id === $alumini->user_id;
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (User::isAdmin()) {
return 'this is the admin page';
} else {
return redirect('404');
}
return $next($request);
}
示例5: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$user = new User();
if ($user->isAdmin()) {
return true;
} else {
return redirect()->to('/');
}
}
示例6: edit
public function edit(User $user, CodeWarQuestion $question)
{
if ($user->isSuperAdmin()) {
return true;
}
if (!$user->isAdmin()) {
return false;
}
return $question->user_id == $user->id;
}
示例7: edit
public function edit(User $user, Quote $quote)
{
if ($user->isSuperAdmin()) {
return true;
}
if (!$user->isAdmin()) {
return false;
}
return $quote->user_id == $user->id;
}
示例8: getIndex
public function getIndex()
{
// ------------------------------------------------------------------------------------------------------------
// WRITER LIST
// ------------------------------------------------------------------------------------------------------------
$writers = User::isAdmin(true)->orderBy('name')->get();
$writer_list = $writers->lists('name', 'id');
// ------------------------------------------------------------------------------------------------------------
// STATUS LIST
// ------------------------------------------------------------------------------------------------------------
foreach (Article::statusList() as $status) {
$status_list[$status] = ucwords($status);
}
// ------------------------------------------------------------------------------------------------------------
// QUERY INDEX
// ------------------------------------------------------------------------------------------------------------
$filters = Input::only('title', 'writer', 'status');
$q = Article::latest();
// Filter title
if ($filters['title']) {
$q = $q->NameLike('*' . $filters['title'] . '*');
}
// Filter Status
if ($filters['status']) {
switch (strtolower($filters['status'])) {
case 'published':
$q = $q->published();
break;
case 'draft':
$q = $q->draft();
break;
case 'upcoming':
$q = $q->upcoming();
break;
}
}
// Filter Writer
if ($filters['writer']) {
$q = $q->WriterById($filters['writer']);
$filters['writer_name'] = $writers->find($filters['writer'])->name;
}
$data = $q->paginate(30);
// ------------------------------------------------------------------------------------------------------------
// SHOW DISPLAY
// ------------------------------------------------------------------------------------------------------------
$this->layout->page = view($this->page_base_dir . 'index')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
$this->layout->page->data = $data;
$this->layout->page->writer_list = $writer_list;
$this->layout->page->status_list = $status_list;
$this->layout->page->filters = $filters;
return $this->layout;
}
示例9: answer
/**
* @param User $user
* @param Question $question
* @return bool
*/
public function answer(User $user, Question $question)
{
/**
* If already answered then return false.
*/
if (!is_null($question->answer)) {
return false;
}
if (!$question->approved) {
return false;
}
/**
* If question is asked globally then any admin can Answer
*/
if (is_null($question->for_user_id)) {
return $user->isAdmin() ? true : false;
}
/**
* If User is Answerer
*/
return $user->id == $question->for_user_id;
}
示例10: changeGroupType
public function changeGroupType(User $user, Group $group)
{
return $user->isAdmin();
}
示例11: adminAuthorization
/**
* Determine if the given user is admin
*
* @param User $user
* @return bool
*/
public function adminAuthorization(User $user, Problem $problem)
{
return $user->isAdmin();
}
示例12: getSearchFabrics
public function getSearchFabrics(Request $request)
{
if (Auth::check() && User::isAdmin(Auth::user())) {
$fabric_name = $request->input("name");
$fabrics = Fabric::searchFabric($fabric_name);
return ["result" => true, "msg" => "Fabrics found", "fabrics" => $fabrics];
} else {
return ["result" => false, "msg" => "Session not found or permission denied"];
}
}
示例13: getUsersPanel
public function getUsersPanel()
{
$menuOptions = [0 => ["data-letters" => "", "id" => "home", "text" => "Home", "href" => "/"]];
if (Auth::check()) {
$data = ["admin" => User::isAdmin(Auth::user())];
$users = User::where("id", "!=", Auth::user()->id)->where("deleted", "=", 0)->take(4)->get();
return view("panel.admin-users-panel")->with("data", $data)->with("users", $users);
} else {
return redirect("/")->with("menuOptions", $menuOptions);
}
}
示例14: handleBuyer
/**
* @param \App\User $buyer Acheteur qui vient de remporter une enchère
* @return string
*/
public function handleBuyer($buyer)
{
if (!$buyer->isAdmin() && $buyer->getOnlineBids()->distinct('item_id')->count() === 0 && $buyer->getOnlineItems()->count() === 0) {
$buyer->delete();
Mail::send(['emails.buyerDisabledAccount-html', 'emails.buyerDisabledAccount-text'], compact('buyer'), function ($message) use($buyer) {
$message->to($buyer->email, $buyer->pseudo)->subject('Votre compte a été désactivé (' . $buyer->pseudo . ')');
});
return 'Le compte de l\'acheteur ' . $buyer->pseudo . ' a été désactivé.';
}
}
示例15: before
/**
* @param User $user
*
* @return bool
*/
public function before(User $user, $ability)
{
return $user->isAdmin();
}