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


PHP Request::merge方法代码示例

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


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

示例1: authenticate

 public function authenticate(Request $request)
 {
     // \Cache::flush();
     // grab credentials from the request
     $credentials = $request->only('name', 'password');
     try {
         // attempt to verify the credentials and create a token for the user
         if (!($token = JWTAuth::attempt($credentials))) {
             return response()->json(['message' => 'invalid_credentials'], 401);
         }
     } catch (JWTException $e) {
         // something went wrong whilst attempting to encode the token
         return response()->json(['message' => 'could_not_create_token'], 500);
     }
     //cek double login
     $token = compact('token');
     Input::merge(['token' => $token['token']]);
     $this->model = $this->model->where('name', $credentials['name'])->first();
     if ($request->get('name') != 'admin') {
         //user is login
         $tempStorage = app('\\App\\Http\\Controllers\\TEMPStorage\\UserTempStorage');
         if (!empty($tempStorage->get('id_company', $this->model->id))) {
             return response()->json(['message' => trans('user_already_login')], 500);
         }
     }
     // all good so return the token
     $this->model->update(['login' => 1]);
     $data = json_decode($this->item($this->model, $this->transformer)->morph()->getContent(), true) + $token;
     return $this->response->array($data)->withHeader('Content-Type', 'application/json');
     // return response()->json(compact('token'));
 }
开发者ID:masmike,项目名称:scafolding,代码行数:31,代码来源:AuthController.php

示例2: call

 /**
  * [fungsi untuk memanggil/consume api]     
  * @param  [alamat route]
  * @param  [method]
  * @return [return]
  */
 public function call($route, $method, $credential)
 {
     if (Session::has('token')) {
         Request::merge(['token' => Session::get('token')]);
     }
     $url = url('/');
     $body = Request::all();
     $options = ['params' => $body];
     try {
         $client = new \GuzzleHttp\Client();
         $response = $client->request($method, $url . $route, ['form_params' => Request::all(), 'query' => Request::all(), 'headers' => ['credential' => $credential]]);
         $headers = $response->getHeaders();
         $withToken = [];
         if (isset($headers['Authorization']['0'])) {
             $newToken = str_replace('Bearer ', '', $headers['Authorization']['0']);
             Session::put('token', $newToken);
             $withToken = ['newToken' => $newToken];
         }
         $content = $response->getBody();
         $content = json_decode((new Response($content))->getContent(), true);
         $status = $response->getStatusCode();
         $result = ['content' => $content, 'status' => $status] + $withToken;
         Logs::Logging($url . $route, $method, Request::all(), $result);
         return $result;
         // return (new Response($content, $status))->header('Content-Type', 'application/json');
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         $content = $e->getResponse()->getBody();
         $content = json_decode((new Response($content))->getContent(), true);
         $status = $e->getResponse()->getStatusCode();
         $result = ['content' => $content, 'status' => $status];
         Logs::Logging($url . $route, $method, Request::all(), $result);
         return $result;
     }
 }
开发者ID:masmike,项目名称:scafolding,代码行数:40,代码来源:Consume.php

示例3: updateToitem

 public function updateToitem($data)
 {
     if (Request::has('detail')) {
         if (isset(Request::get('detail')['id_detail'])) {
             Request::merge(Request::get('detail'));
             $soItem = new $this->detailClass();
             $soItem->putUpdate(Request::get('detail')['id_detail']);
         }
     }
 }
开发者ID:masmike,项目名称:scafolding,代码行数:10,代码来源:BaseModulController.php

示例4: scopeSortable

 /**
  * @param \Illuminate\Database\Query\Builder $query
  * @param array|null $defaultSortParameters
  *
  * @return \Illuminate\Database\Query\Builder
  */
 public function scopeSortable($query, $defaultSortParameters = null)
 {
     if (Request::has('sort') && Request::has('order')) {
         return $this->queryOrderBuilder($query, Request::only(['sort', 'order']));
     } elseif (!is_null($defaultSortParameters)) {
         $defaultSortArray = $this->formatToSortParameters($defaultSortParameters);
         if (Config::get('columnsortable.allow_request_modification', true) && !empty($defaultSortArray)) {
             Request::merge($defaultSortArray);
         }
         return $this->queryOrderBuilder($query, $defaultSortArray);
     } else {
         return $query;
     }
 }
开发者ID:kyslik,项目名称:column-sortable,代码行数:20,代码来源:Sortable.php

示例5: filtersMapping

 protected function filtersMapping()
 {
     if (Request::has('searchText') && Request::has('searchCol')) {
         if (strtolower(Request::get('searchCol')) == 'login') {
             if (strtolower(Request::get('searchText')) == 'online') {
                 Request::merge(['searchText' => '1']);
             } else {
                 if (strtolower(Request::get('searchText')) == 'offline') {
                     Request::merge(['searchText' => '0']);
                 }
             }
         }
     }
 }
开发者ID:masmike,项目名称:scafolding,代码行数:14,代码来源:MasterUserController.php

示例6: filtersMapping

 protected function filtersMapping()
 {
     if (Request::has('searchText') && Request::has('searchCol')) {
         if (strtolower(Request::get('searchCol')) == 'status') {
             if (strtolower(Request::get('searchText')) == 'confirm') {
                 Request::merge(['searchText' => '1']);
             } else {
                 if (strtolower(Request::get('searchText')) == 'open') {
                     Request::merge(['searchText' => '0']);
                 } else {
                     if (strtolower(Request::get('searchText')) == 'void') {
                         Request::merge(['searchText' => '2']);
                     }
                 }
             }
         }
     }
 }
开发者ID:masmike,项目名称:scafolding,代码行数:18,代码来源:PurchaseOrderController.php

示例7: putKonversi

 /**
  * [postKonversi description]
  * @return view konversi form
  */
 public function putKonversi()
 {
     if (!Request::has('id_unit')) {
         Request::merge(['id_unit' => '0']);
     }
     $response = $this->call('/api/' . $this->url . '/' . Request::get('id'), 'put');
     if ($response['status'] == 201) {
         $data = !empty($response['content']['data']) ? $response['content']['data'] : '';
     } else {
         $data = Request::all();
     }
     $data = ['data' => $data, 'label' => $this->label, 'url' => $this->url, 'view' => $this->view];
     if (method_exists($this, 'formApi')) {
         $data += $this->formApi();
     }
     $this->setflashSuccess($response);
     return redirect('/master/items/konversi/' . Request::get('id'));
 }
开发者ID:masmike,项目名称:scafolding,代码行数:22,代码来源:ItemController.php

示例8: getIndex

 /**
  * get index 
  *
  * @param  array  $data
  * @return \Illuminate\Contracts\Validation\Validator
  */
 public function getIndex()
 {
     // set default limit
     if (Request::has('length')) {
         $this->length = Request::get('length');
     } else {
         if (Session::has('length')) {
             $this->length = Session::get('length');
         } else {
             $this->length = 10;
         }
     }
     Session::put('length', $this->length);
     Request::merge(['limit' => $this->length]);
     $response = $this->call('/api/' . $this->url, 'get');
     // echo \DNS1D::getBarcodeSVG("4445645656", "PHARMA2T");die();
     // return \PDF::loadFile('http://www.github.com')->stream('github.pdf');
     return view('web.' . $this->view . '.index', ['data' => !empty($response['content']['data']) ? $response['content']['data'] : '', 'label' => $this->label, 'url' => $this->url, 'view' => $this->view, 'menuPermission' => Session::get('rolePermission')['/' . $this->url][0], 'length' => !empty($response['content']['meta']['pagination']['per_page']) ? $response['content']['meta']['pagination']['per_page'] : ''])->with(['paginated' => $this->paginate($response['content'])]);
 }
开发者ID:masmike,项目名称:scafolding,代码行数:25,代码来源:BaseForWebController.php

示例9: postStore

 /**
  * Store a new data in the database.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postStore()
 {
     if (!$this->apiHelper) {
         $this->authorize('add');
     }
     DB::beginTransaction();
     if (method_exists($this, 'beforeStore')) {
         $this->beforeStore();
     }
     $v = Validator::make(Input::all(), $this->postStoreRules);
     if ($v->fails()) {
         throw new \Dingo\Api\Exception\StoreResourceFailedException(trans('response.unprocessable'), $v->errors());
     }
     //set dynamic transformer
     if (!empty($this->transformerStore)) {
         $this->transformer = new $this->transformerStore();
     }
     if ($this->apiCompany) {
         if (empty($this->tempStorage)) {
             $this->invalidateToken();
             throw $this->response->errorNotFound(trans('response.no_company_chosen'));
         }
         Input::merge(['id_company' => $this->tempStorage->get('id_company')]);
     }
     if ($data = $this->model->create(Input::all())) {
         if (method_exists($this, 'afterStore')) {
             $this->afterStore($data);
         }
         DB::commit();
         return $this->response->created()->setContent($this->item($data, $this->transformer)->morph()->getContent())->withHeader('Content-Type', 'application/json');
     } else {
         DB::rollback();
         throw $this->response->error(trans('response.save_failed'), 404);
     }
 }
开发者ID:masmike,项目名称:scafolding,代码行数:41,代码来源:BaseController.php

示例10: validateCurrentIp

 /**
  * Convert an attribute value to current user IP address (e.g: 127.0.0.1)
  *
  * @param  string  $attribute
  * @param  mixed   $value
  * @return bool
  */
 protected function validateCurrentIp($attribute, $value)
 {
     Request::merge([$attribute => (string) _current_ip()]);
     return true;
 }
开发者ID:moh8med,项目名称:laravel-validator,代码行数:12,代码来源:LaravelValidator.php


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