本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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));
}
}