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


PHP Resource::all方法代碼示例

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


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

示例1: run

 public function run()
 {
     DB::table('permissions')->delete();
     $roles = array();
     $roles[0] = Role::where('name', '=', 'admin')->first()->id;
     $roles[1] = Role::where('name', '=', 'moderator')->first()->id;
     $resources = Resource::all();
     $actions = array();
     $actions[0] = Action::where('name', '=', 'manage')->first()->id;
     /*
     $actions[0]  = Action::where('name','=','create')->first()->id;
     $actions[1]  = Action::where('name','=','read')->first()->id;
     $actions[2]  = Action::where('name','=','update')->first()->id;
     $actions[3]  = Action::where('name','=','delete')->first()->id
     */
     $data = array();
     foreach ($roles as $role) {
         foreach ($resources as $resource) {
             foreach ($actions as $action) {
                 $data[] = array('role_id' => $role, 'type' => $role == $roles[0] || $resource->name != 'role' && $resource->name != 'auth' ? 'allow' : 'deny', 'action_id' => $action, 'resource_id' => $resource->id);
             }
         }
     }
     DB::table('permissions')->insert($data);
 }
開發者ID:Metrakit,項目名稱:dynamix,代碼行數:25,代碼來源:PermissionsTableSeeder.php

示例2: get

 /**
  * Get a single resource by name.
  * @param  string $resource_name the resource name
  * @return Resource
  * @throws Resource_Exception_Notfound If the resource is not found
  */
 public static function get($resource_name)
 {
     if (!($resource = Arr::get(Resource::all(), $resource_name))) {
         throw new Kohana_Exception('Resource :resource is not defined!', array(':resource' => $resource_name));
     }
     return $resource;
 }
開發者ID:openbuildings,項目名稱:jam-resource,代碼行數:13,代碼來源:Resource.php

示例3: _execute

 protected function _execute(array $options)
 {
     $resources_string = '';
     $resources = isset($options[1]) ? explode(',', $options[1]) : Resource::all();
     foreach ($resources as $resource) {
         if (is_numeric($resource)) {
             continue;
         }
         if (is_string($resource)) {
             $resource = Resource::get($resource);
         }
         if (!$resource->parent()) {
             $resources_string .= $this->_resource($resource);
         }
     }
     Minion_CLI::write($resources_string);
 }
開發者ID:openbuildings,項目名稱:jam-resource,代碼行數:17,代碼來源:Index.php

示例4: addphotos

 public function addphotos()
 {
     $resources = Resource::all();
     $photos = Photo::owned(Auth::user()->ID)->get();
     if (Request::ajax()) {
         $resource = Resource::find(Input::get('resource_id'));
         $photo_id = Input::get('photo_id');
         //validating the user ownership in photos
         $photo_id = Photo::owned(Auth::user()->ID)->where("id", "=", $photo_id)->get()->first();
         $resource->photos()->attach($photo_id);
     }
     if (Auth::user()->role == 'admin' || Auth::user()->role == 'teacher') {
         $this->layout->content = View::make("resources.addphotos")->with(array('resources' => $resources, 'photos' => $photos));
     } else {
         return View::make("resources.addphotos-kids")->with(array('resources' => $resources, 'photos' => $photos));
     }
 }
開發者ID:shankargiri,項目名稱:Quantum-Vic-La-Trobe-L4,代碼行數:17,代碼來源:ResourcesController.php


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