当前位置: 首页>>代码示例>>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;未经允许,请勿转载。