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


PHP Requests::retrieve方法代码示例

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


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

示例1: index

 /**
  * Display a listing of requests.
  *
  * @return Response
  */
 public function index()
 {
     //get user role
     $user = Sentry::getUser();
     $role = $user->role;
     Input::get('reqCode') ? $reqCode = Input::get('reqCode') : ($reqCode = '');
     Input::get('roleId') ? $roleId = Input::get('roleId') : ($roleId = $role->id);
     Input::get('type') ? $type = Input::get('type') : ($type = 'license');
     if ($role->role != 'All' && $role->id != $roleId) {
         return Redirect::to('/')->with('error', 'Cannot access that EC');
     }
     if ($role->role == 'All') {
         if (!$reqCode) {
             $reqCode = 1;
         }
         //ASAP
         if ($roleId == 1) {
             $roleId = '';
         }
     }
     //get the requests
     $requests = Request::retrieve($roleId, $reqCode, $type);
     //ajax request so return json
     if ($this->httpRequest->ajax()) {
         //make table headers
         $header = array(Lang::get('request.requester'), Lang::get('general.unit'), Lang::get('general.ec'), Lang::get('request.for'), Lang::get('licenses.general.type'), Lang::get('request.dateReq'), Lang::get('general.actions'));
         $return = array();
         foreach ($requests as $key => $request) {
             $return[$key] = new \stdClass();
             $return[$key]->id = $request->id;
             $return[$key]->requester = $request->owner->first_name . " " . $request->owner->last_name;
             $return[$key]->unit = $request->unit->name;
             $return[$key]->role = $request->roles->role;
             $request->account ? $return[$key]->name = $request->account->first_name . " " . $request->account->last_name : ($return[$key]->name = '');
             if ($type == 'license') {
                 $return[$key]->lcnsTypes = $request->licenseTypes;
             } elseif ($type == 'checkin') {
                 $return[$key]->lcnsName = $request->licenseSeat->license->name;
             }
             $return[$key]->created_at = (string) $request->created_at;
             $return[$key]->actions = '';
             //delete
             if ($user->role->id == $requests[$key]->role_id || in_array('Authorizers', $user->group())) {
                 $return[$key]->actions .= "<a href=" . URL::to('request/' . $requests[$key]->id) . " class='delete-request'><i class='fa fa-trash icon-white'></i></a>";
             } elseif (in_array('Admin', $user->group())) {
                 $return[$key]->actions .= "<a href=" . URL::to('request/' . $requests[$key]->id) . " class='delete-request'><i class='fa fa-trash icon-white'></i></a>";
             }
             //edit
             if (($user->hasAccess('authorize') || $user->role->id == $requests[$key]->role_id) && empty($request->request_code)) {
                 $return[$key]->actions .= "<a href=" . URL::to('request/' . $requests[$key]->id . '/edit') . "><i class='fa fa-pencil icon-white'></i></a>";
             }
             //approve
             if (in_array('Authorizers', $user->group()) && empty($request->request_code) || in_array('Admin', $user->group()) && $request->request_code == 1) {
                 $return[$key]->actions .= "<a href=" . URL::to('request/' . $request->id . '/approve') . "><i class='fa fa-check icon-blue'></i></a>";
             }
         }
         if (!$return) {
             $return = "No requests found";
         }
         header('Content-type: application/json');
         //return Response::json(array('requests'=>$requests, 'isAdmin' => $user->hasAccess('admin'), 'roleId' => $user->role->id), 200);
         echo json_encode(array('requests' => $return, 'header' => $header, 'isAdmin' => $user->hasAccess('admin'), 'roleId' => $user->role->id));
     } else {
         //html request
         return View::make('backend.requests.index')->with('requests', $requests)->with('user', $user)->with('roleId', $roleId)->with('type', $type);
     }
 }
开发者ID:amcfarlane1251,项目名称:lcnsMgmt,代码行数:72,代码来源:RequestsController.php


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