當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Role::exists方法代碼示例

本文整理匯總了PHP中Role::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::exists方法的具體用法?PHP Role::exists怎麽用?PHP Role::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Role的用法示例。


在下文中一共展示了Role::exists方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: foreach

 function roles_post()
 {
     $requested_data = json_decode($this->post('models'));
     foreach ($requested_data as $d) {
         $user = new User(null, $this->entity);
         $user->where('id', $d->user_id);
         $user->get();
         $role = new Role(null, $this->entity);
         $role->where('id', $d->role_id);
         $role->get();
         if ($user->exists() && $role->exists()) {
             if ($user->save($role)) {
                 $r = $user->include_related('role', NULL, TRUE)->get_raw();
                 $this->response(array('msg' => 'assigned successfully.', 'results' => $r->result()), 201);
             } else {
                 $this->response(array('msg' => 'error assigning to role.', 'results' => array()), 201);
             }
         } else {
             $this->response(array('msg' => 'either role or user does not exist', 'results' => array()), 201);
         }
     }
     // $this->response(array('msg'=>'assigned successfully.', 'results'=>$r->result()), 201);
 }
開發者ID:nicarayz,項目名稱:linabiz,代碼行數:23,代碼來源:users.php

示例2: foreach

 function user_put()
 {
     $model = json_decode($this->put('models'));
     foreach ($model as $d) {
         $user = new User(null, $this->entity);
         $user->where('id', $d->user);
         $user->get();
         $role = new Role(null, $this->entity);
         $role->where('id', $d->role);
         $role->get();
         if ($user->exists() && $role->exists()) {
             $user->set_join_field($role, 'role_id', $d->role);
             if ($user->save($role)) {
                 $this->response(array('msg' => 'assigned'), 201);
             }
         }
         // $this->response(array('user'=>$user->id), 201);
     }
     // $this->response(array('user'=>$model[0]->user), 201);
 }
開發者ID:nicarayz,項目名稱:linabiz,代碼行數:20,代碼來源:roles.php

示例3: remove_role_from_user

 /**
  * Remove Role From User
  * Removes a role from a user
  * 
  * @param mixed $user_id
  * @param mixed $role_id
  */
 public function remove_role_from_user($user_id, $role_id)
 {
     $u = new User($user_id);
     $r = new Role($role_id);
     if ($u->exists() and $r->exists()) {
         $u->delete($r);
     }
 }
開發者ID:Moro3,項目名稱:duc,代碼行數:15,代碼來源:Auth_simpleauth.php


注:本文中的Role::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。