public function actionViews() { $id_article = Request::get('id'); $model = new Article(); $this->view->model = $model->getOne($id_article); echo $this->view->render('views'); }
public function setPasswordAttribute($value) { if (!\Request::has('password')) { if ($value) { $this->attributes['password'] = $value; } else { $this->attributes['password'] = $this->password; } } else { $this->attributes['password'] = \Hash::make(\Request::get('password')); } }
/** * scope query with filter options * @param query $query * @return Query */ public static function scopeFilter($query) { if ($name = \Request::get('q')) { $query->where('name', 'like', "%{$name}%"); $query->orWhere('asset_no', 'like', "%{$name}%"); $query->orWhere('model', 'like', "%{$name}%"); } if ($category_id = \Request::get('category_id')) { $query->where('category_id', '=', $category_id); } if ($department_id = \Request::get('department_id')) { $query->where('department_id', '=', $department_id); } if ($vendor_id = \Request::get('vendor_id')) { $query->where('vendor_id', '=', $vendor_id); } if ($status = \Request::get('status')) { $query->where('status', '=', $status); } return $query; }
public function assignRoleUser($rid) { // get the query string from the url $uid = Request::get('uid'); // find the user and update the user role. $user = User::find($uid); $user->role_id = $rid; $user->save(); //return response as JSON return Response::json($user); }
/** * @param Request $request * @param string $paramName * * @return Response */ public function getByIdAction(Request $request, $paramName) { $data = $this->model->getById($request->get($paramName)); return new Response($data); }
public static function drawSearch(ModelConfig $modelConfig, $searchParams = false) { $html = \Form::open(array('method' => 'get', 'url' => '/admin/' . $modelConfig->name, 'class' => 'searchForm model' . $modelConfig->name . " " . ($modelConfig->form && $modelConfig->form->horizontal ? ' form-horizontal' : ''))); $labelClass = ""; if ($modelConfig->searchForm && $modelConfig->searchForm->horizontal) { $labelClass = " control-label col-sm-" . $modelConfig->searchForm->labelWidth; } foreach ($modelConfig->getFormFields('all', true) as $field) { if ($field->restrictedToSuperadmin && !\Auth::user()->is_superadmin) { continue; } $userRole = \Auth::user()->role; if ($field->restrictedAccess && !$field->restrictedAccess->{$userRole}) { continue; } if ($field->search) { $html .= "<div class='form-group'>"; $options = array('class' => ' form-control '); if ($field->options) { foreach ($field->options as $key => $value) { if ($key == 'class') { $options[$key] .= $value; } else { if ($key == 'readonly') { $options[$key] = 'readonly'; } else { //ignore other options for search } } } } if ($field->search->type == 'standard') { $label = $field->search->label ? $field->search->label : $field->label; if (!in_array($field->type, array('checkbox', 'radio', 'hidden'))) { $html .= \Form::label("search_" . $field->property, $label, array('class' => $labelClass)); } if ($modelConfig->searchForm && $modelConfig->searchForm->horizontal) { $class = "col-sm-" . $modelConfig->searchForm->inputWidth; if (in_array($field->type, array('checkbox', 'radio'))) { $class .= " col-sm-offset-" . $modelConfig->searchForm->labelWidth; } $html .= "<div class='" . $class . "'>"; } if ($field->type == 'text' || $field->type == 'textarea') { $html .= \Form::text("search_" . $field->property, \Request::get("search_" . $field->property), $options); } else { if ($field->type == 'checkbox') { $html .= "<div class='checkbox'><label>"; $html .= \Form::checkbox("search_" . $field->property, 1, \Request::get("search_" . $field->property)); $html .= " " . $label . "</label></div>"; } else { if (in_array($field->type, array('select', 'multiSelect'))) { $listMethod = $field->selectType->listMethod; $options['class'] = ''; $list = array(); if ($field->selectType->type == 'model') { $selectModel = $field->selectType->modelName; $fullModelName = ModelConfig::fullEntityName($selectModel); if ($field->selectType->callMethodOnInstance) { $list = array(); } else { $list = $fullModelName::$listMethod('id'); } if ($field->selectType->ajax) { $options['data-searchfields'] = implode('|', AdminHelper::objectToArray($field->selectType->ajax->searchFields)); $options['data-model'] = $field->selectType->modelName; $options['data-value'] = $field->selectType->ajax->value; $options['data-text'] = $field->selectType->ajax->text; $options['class'] .= " ajax "; } } else { if ($field->selectType->type == 'list') { $entity = $modelConfig->myFullEntityName(); $list = $entity::$listMethod(); } } if (!is_array($list) && is_object($list)) { $reflection = new \ReflectionClass($list); if ($reflection->getShortName() == "Collection") { /** @var \Illuminate\Support\Collection $list */ $list = $list->toArray(); } } $null = array('' => '-'); $list = $null + $list; $options['class'] .= ' selectizeNoCreate doSelectize'; $html .= \Form::select("search_" . $field->property, $list, \Request::get("search_" . $field->property), $options); } else { if (in_array($field->type, array('date', 'dateTime'))) { if ($field->type == 'date') { $options['class'] .= ' datePicker '; } else { if ($field->type == 'dateTime') { $options['class'] .= ' dateTimePicker '; } } $html .= \Form::text("search_" . $field->property, \Request::get("search_" . $field->property), $options); } } } } } else { if ($field->search->type == 'exception') { //custom code here } } if ($modelConfig->searchForm && $modelConfig->searchForm->horizontal) { $html .= "</div>"; } $html .= "</div>"; } } $html .= \Form::submit(trans('gtcms.search'), array('class' => 'btn btn-default cBoth floatNone')); $html .= "\n\t\t\t<div class='formSubmitMessage'>\n\t\t\t\t<div class='formSpinner'></div>\n\t\t\t\t<span class='errorMessage'></span>\n\t\t\t</div>\n\t\t"; $html .= \Form::close(); return $html; }