當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。