当前位置: 首页>>代码示例>>PHP>>正文


PHP Resource::where方法代码示例

本文整理汇总了PHP中Resource::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::where方法的具体用法?PHP Resource::where怎么用?PHP Resource::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resource的用法示例。


在下文中一共展示了Resource::where方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Config::get('validator.admin.role'));
     if ($validator->passes()) {
         $role = new Role();
         $role->name = Input::get('name');
         $role->deletable = 1;
         // Was the blog post created?
         if ($role->save()) {
             //Set all permission to deny
             $resources = Resource::where('in_admin_ui', '=', 1)->get();
             $data = array();
             foreach ($resources as $resource) {
                 foreach (Action::all() as $action) {
                     $data[] = array('role_id' => $role->id, 'type' => 'deny', 'action_id' => $action->id, 'resource_id' => $resource->id);
                 }
             }
             DB::table('permissions')->insert($data);
             //track user
             parent::track('create', 'Role', $role->id);
             return Redirect::to('admin/role_permission')->with('success', Lang::get('admin.role_save_success'));
         }
         // Redirect to the blog post create role
         return Redirect::to('admin/role/create')->with('error', Lang::get('admin.role_save_fail'));
     }
     // Form validation failed
     return Redirect::to('admin/role/create')->withInput()->withErrors($validator);
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:33,代码来源:AdminRoleController.php

示例2: hasPermission

 /**
  * hasPermissions
  *
  */
 public function hasPermission($action, $resource)
 {
     $action_id = Action::where('name', '=', $action)->first()->id;
     $resource_id = Resource::where('name', '=', $resource)->first()->id;
     foreach ($this->roles as $role) {
         foreach ($role->permissionsAllowed as $permission) {
             if ($permission->action_id == $action_id && $permission->resource_id == $resource_id) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:17,代码来源:AuthUser.php

示例3: getResourceNotAllowed

 /**
  * return an array of Object for all not allowed resources
  *
  * @return array
  */
 protected function getResourceNotAllowed()
 {
     $notAllowed = array();
     $resourceNavigable = Resource::where('navigable', '=', 1)->get();
     foreach ($resourceNavigable as $resource) {
         $modelName = $resource->model;
         //Si la clé allowed['resource'] exists, put the objet in this
         $objects = $modelName::getNotAllowed();
         if (count($objects) > 0) {
             if (isset($notAllowed[$modelName])) {
                 $notAllowed[$modelName] = array_merge($notAllowed[$modelName], $objects);
             } else {
                 $notAllowed[$modelName] = $objects;
             }
         }
     }
     return $notAllowed;
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:23,代码来源:BaseController.php

示例4: lookResrc

 public function lookResrc()
 {
     if (Request::ajax()) {
         $keyword = Input::get('keyword');
         $resrc = Resource::where('name', 'LIKE', "%m%");
         return $resrc->name;
     }
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:8,代码来源:ResourcesController.php

示例5: initCache

    public function initCache()
    {
        // !!! DATABASE CACHE !!!
        //Cache Model::Menu
        //Cache::forget('DB_Menu');
        /*Cache::rememberForever('DB_Menu', function()
        		{
        		    return Menu::where('parent_id','=',0)->orderBy('order','ASC')->get();
        		});*/
        //Cache Model::Locale
        Cache::rememberForever('DB_LocaleFrontEnable', function () {
            //Get all data in database
            $locales = Locale::where('enable', '=', 1)->where('is_publish', '=', 1)->get();
            //Preapre data to extract by id
            $data = array();
            foreach ($locales as $l) {
                $data[] = $l->id;
            }
            return $data;
        });
        //Cache Model::Nav
        Cache::rememberForever('DB_Nav', function () {
            return Nav::where('parent_id', '=', 0)->orderBy('order', 'ASC')->get();
        });
        //Cache Model::Resource('name')
        Cache::rememberForever('DB_AdminResourceName', function () {
            //Get all data in database
            $resources = Resource::where('in_admin_ui', '=', 1)->get();
            //Preapre data to extract by id
            $data = array();
            foreach ($resources as $r) {
                $data[$r->id] = $r->name;
            }
            return $data;
        });
        Cache::rememberForever('DB_AdminResource', function () {
            //Get all data in database
            return Resource::where('in_admin_ui', '=', 1)->get();
        });
        Cache::rememberForever('DB_AdminResourceNavigable', function () {
            //Get all data in database
            return Resource::where('navigable', '=', 1)->where('in_admin_ui', '=', 1)->get();
        });
        // Get all Locales enableds in the table
        Cache::rememberForever('DB_LocalesEnabled', function () {
            return Locale::where('enable', 1)->where('is_publish', 1)->get();
        });
        Cache::rememberForever('DB_AdminBlockTypes', function () {
            //Get all data in database
            return BlockType::all();
        });
        //Cache Model::Mosaique('name')
        //Cache::forget('DB_Mosaique');
        /*Cache::rememberForever('DB_Mosaique', function()
        		{
        			//Get all data in database
        		    return Mosaique::all();
        		});*/
        //Cache Model::Option
        Cache::rememberForever('DB_Option', function () {
            return Option::all();
        });
        //Cache Model::Urls
        Cache::rememberForever('DB_Urls', function () {
            $data = DB::select('
		    	SELECT translations.i18n_id , translations.text , translations.locale_id 
				FROM translations
				INNER JOIN i18n_types ON i18n_types.name = ?
				INNER JOIN i18n ON i18n.i18n_type_id = i18n_types.id AND translations.i18n_id = i18n.id
		    ', array('url'));
            //$data = Translation::i18n()->where('i18n_type_id','=',I18nType::where('name','=','url')->first()->id)->get
            $datas = array();
            foreach ($data as $d) {
                $datas[] = array('i18n_id' => $d->i18n_id, 'url' => $d->text, 'locale_id' => $d->locale_id);
            }
            return $datas;
        });
    }
开发者ID:Metrakit,项目名称:dynamix,代码行数:78,代码来源:Cachr.php

示例6: function

<?php

Route::group(["before" => "guest"], function () {
    if (Schema::hasTable('resource')) {
        $resources = Resource::where("secure", false)->get();
        foreach ($resources as $resource) {
            Route::any($resource->pattern, ["as" => $resource->name, "uses" => $resource->target]);
        }
    }
});
Route::group(["before" => "auth"], function () {
    if (Schema::hasTable('resource')) {
        $resources = Resource::where("secure", true)->get();
        foreach ($resources as $resource) {
            Route::any($resource->pattern, ["as" => $resource->name, "uses" => $resource->target]);
        }
    }
});
开发者ID:alejandromorg,项目名称:Inventario,代码行数:18,代码来源:routes.php

示例7: editAction

 public function editAction()
 {
     /*
     FALTA
     */
     $form = new GroupForm();
     $id = Input::get("id");
     $group = Group::findOrFail($id);
     $url = URL::full();
     if ($form->isPosted()) {
         if ($form->isValidForEdit()) {
             $group->name = Input::get("name");
             $group->save();
             $group->users()->sync(Input::get("user_id", []));
             $group->resources()->sync(Input::get("resource_id", []));
             return Redirect::route("group/index");
         }
         return Redirect::to($url)->withInput(["name" => Input::get("name"), "errors" => $form->getErrors(), "url" => $url]);
     }
     //die(var_dump($group));
     return View::make("group/edit", ["form" => $form, "group" => $group, "users" => User::all(), "HeaderTitle" => "EDIT GROUP", "resources" => Resource::where("secure", true)->get()]);
 }
开发者ID:alejandromorg,项目名称:Inventario,代码行数:22,代码来源:GroupController.php


注:本文中的Resource::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。