当前位置: 首页>>代码示例>>PHP>>正文


PHP User::hasPermission方法代码示例

本文整理汇总了PHP中app\models\User::hasPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP User::hasPermission方法的具体用法?PHP User::hasPermission怎么用?PHP User::hasPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::hasPermission方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 /**
  * @param User $user
  * @param Document $document
  * @return bool
  */
 public static function view(User $user, $document)
 {
     if ($user->hasPermission('view_all')) {
         return true;
     }
     if ($document->expense) {
         if ($document->expense->invoice) {
             return $user->can('view', $document->expense->invoice);
         }
         return $user->can('view', $document->expense);
     }
     if ($document->invoice) {
         return $user->can('view', $document->invoice);
     }
     return $user->owns($item);
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:21,代码来源:DocumentPolicy.php

示例2: create

 /**
  * @param User $user
  * @return bool
  */
 public static function create(User $user, $item)
 {
     return $user->hasPermission('admin');
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:8,代码来源:TaxRatePolicy.php

示例3: User

    echo 1;
}
use app\models\Session;
use app\models\User;
use app\classes\DB;
$user = DB::connect();
if (Session::exists('home')) {
    echo "<p><b>" . Session::flash('home') . "</b></p>";
}
$user = new User();
if ($user->isLoggedIn()) {
    ?>
    <p>Hello, <a href="profile.php?user=<?php 
    echo escape($user->data()->username);
    ?>
"><?php 
    echo $user->data()->username;
    ?>
</a></p>
    <ul>
        <li>You can <a href="logout.php">log out</a> here!</li>
        <li>You can <a href="update.php">update</a> your profile here!</li>
        <li>You can <a href="changepassword.php">change password</a> here!</li>
    </ul>
    <?php 
    if ($user->hasPermission('admin')) {
        echo 'You are  an admin';
    }
} else {
    echo "<p>You need to <a href='login.php'>log in</a> or <a href='register.php'>register</a>!" . "</p>";
}
开发者ID:sydorenkovd,项目名称:test-items,代码行数:31,代码来源:index.php

示例4: editByOwner

 /**
  * @param User $user
  * @param $ownerUserId
  * @return bool
  */
 public static function editByOwner(User $user, $ownerUserId)
 {
     return $user->hasPermission('edit_all') || $user->id == $ownerUserId;
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:9,代码来源:EntityPolicy.php

示例5: destroy

 /**
  * Determine if the given permission can be destroyed by the user.
  *
  * @param  \App\User  $user
  * @param  \App\Model\Permission  $permission
  * @return bool
  */
 public function destroy(\App\Models\User $user, \App\Models\Permission $permission)
 {
     return $user->hasPermission('permission.destroy');
 }
开发者ID:jaffarhussain1011,项目名称:laravel-authorization-demo,代码行数:11,代码来源:PermissionPolicy.php

示例6: destroy

 /**
  * Determine if the given role can be destroyed by the user.
  *
  * @param  \App\User  $user
  * @param  \App\Model\Role  $role
  * @return bool
  */
 public function destroy(\App\Models\User $user, \App\Models\Role $role)
 {
     return $user->hasPermission('role.destroy');
 }
开发者ID:jaffarhussain1011,项目名称:laravel-authorization-demo,代码行数:11,代码来源:RolePolicy.php


注:本文中的app\models\User::hasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。