本文整理汇总了PHP中Request::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::has方法的具体用法?PHP Request::has怎么用?PHP Request::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsers
public function getUsers(Request $request)
{
$yetkiler = Role::all();
$count = $request->get('count');
$page = $request->get('page');
$filters = $request->get('filter');
$sorting = $request->get('sorting');
$results = new User();
if (is_array($filters)) {
foreach ($filters as $key => $filter) {
$results = $results->where($key, 'like', "%" . urldecode($filter) . "%");
}
}
if (is_array($sorting)) {
foreach ($sorting as $key => $sort) {
$results = $results->orderBy($key, $sort);
}
} else {
$results = $results->orderBy('id', 'desc');
}
if ($request->has('count') && $request->has('page')) {
$results = $results->skip($count * ($page - 1))->take($count);
}
$results = $results->get();
$filter_yetkiler = Role::select('id', 'display_name as title')->get();
return array('results' => $results, 'inlineCount' => User::count(), 'yetkiler' => $yetkiler, 'filter_yetkiler' => $filter_yetkiler);
}
示例2: index
public function index()
{
$post = array('alert' => '');
Model::load('admincp/comments');
if ($match = Uri::match('\\/comments\\/(\\w+)')) {
if (method_exists("controlComments", $match[1])) {
$method = $match[1];
$this->{$method}();
die;
}
}
$curPage = 0;
if ($match = Uri::match('\\/page\\/(\\d+)')) {
$curPage = $match[1];
}
if (Request::has('btnAction')) {
actionProcess();
}
if (Request::has('btnSearch')) {
filterProcess();
} else {
$post['pages'] = Misc::genSmallPage('admincp/comments', $curPage);
$filterPending = '';
if (Uri::has('\\/status\\/pending')) {
$filterPending = " AND c.status='0' ";
}
$post['theList'] = Comments::get(array('limitShow' => 20, 'limitPage' => $curPage, 'query' => "select c.*,p.title from " . Database::getPrefix() . "post p," . Database::getPrefix() . "comments c where c.postid=p.postid order by c.commentid desc", 'cacheTime' => 1));
}
System::setTitle('Comments list - ' . ADMINCP_TITLE);
View::make('admincp/head');
self::makeContents('commentsList', $post);
View::make('admincp/footer');
}
示例3: index
public function index()
{
$dataAccess = new ClientMng();
//$clients = $dataAccess->getClientsFromUsers();
$request = Request::create('/api/clients', 'GET');
$response = Route::dispatch($request);
$obj = json_decode($response->content(), true);
$clients = $obj["data"];
if (\Request::has('search')) {
$query = \Request::get('search');
$results = $dataAccess->search($query);
if (count($results) < 1) {
$results = $dataAccess->searchRaw($query);
}
return \View::make('clientlist')->with('clients', $results);
}
//$obj2 = $obj["data"];
// foreach($obj as $i)
// {
// //echo $i[1]["firstName"];
// //echo print_r($i);
// array_push($obj2, $i);
// }
//echo $response;
//echo print_r($obj2);
//echo $clients[0]["id"];
//echo $response->content();
//echo print_r($obj2);
return \View::make('clientlist')->with('clients', $clients);
}
示例4: getResult
public function getResult($id = 'x')
{
$printed = \Request::get('printed');
$slctd_samples = \Request::has("samples") ? \Request::get("samples") : [];
$slctd_samples_str = is_array($slctd_samples) ? implode(',', $slctd_samples) : "{$slctd_samples}";
$sql = "SELECT s.*, p.artNumber,p.otherID, p.gender, p.dateOfBirth,\n\t\t\t\tGROUP_CONCAT(ph.phone SEPARATOR ',') AS phone, f.facility, d.district, h.hub AS hub_name, \n\t\t\t\tGROUP_CONCAT(res_r.Result, '|||', res_r.created SEPARATOR '::') AS roche_result,\n\t\t\t\tGROUP_CONCAT(res_a.result, '|||', res_a.created SEPARATOR '::') AS abbott_result,\n\t\t\t\tGROUP_CONCAT(res_o.result, '|||', res_o.created SEPARATOR '::') AS override_result,\n\t\t\t\tlog_s.id AS repeated, v.outcome AS verify_outcome, reason.appendix AS rejection_reason,\n\t\t\t\tu.signaturePATH, wk.machineType, fctr.factor, sw.sampleID, sw.worksheetID\n\t\t\t\tFROM vl_samples AS s\n\t\t\t\tLEFT JOIN vl_facilities AS f ON s.facilityID=f.id\n\t\t\t\tLEFT JOIN vl_districts AS d ON f.districtID=d.id\n\t\t\t\tLEFT JOIN vl_hubs AS h ON f.hubID=h.id\n\t\t\t\tLEFT JOIN vl_patients As p ON s.patientID=p.id\n\t\t\t\tLEFT JOIN vl_patients_phone As ph ON p.id = ph.patientID\n\t\t\t\tLEFT JOIN vl_samples_verify AS v ON s.id=v.sampleID\t\t\t\t\n\t\t\t\tLEFT JOIN vl_appendix_samplerejectionreason AS reason ON v.outcomeReasonsID=reason.id\n\t\t\t\tLEFT JOIN vl_samples_worksheet AS sw ON s.id=sw.sampleID\n\t\t\t\tLEFT JOIN vl_samples_worksheetcredentials AS wk ON sw.worksheetID=wk.id\n\t\t\t\tLEFT JOIN vl_results_roche AS res_r ON s.vlSampleID = res_r.SampleID\n\t\t\t\tLEFT JOIN vl_results_abbott AS res_a ON s.vlSampleID = res_a.SampleID\n\t\t\t\tLEFT JOIN vl_results_override AS res_o ON s.vlSampleID = res_o.sampleID\n\t\t\t\tLEFT JOIN vl_logs_samplerepeats AS log_s ON s.id = log_s.sampleID\n\t\t\t\tLEFT JOIN vl_users AS u ON wk.createdby = u.email\n\t\t\t\tLEFT JOIN vl_results_multiplicationfactor AS fctr ON wk.id=fctr.worksheetID\n\t\t\t\tWHERE\n\t\t\t\t";
if ($id == 'x' and count($slctd_samples) == 0) {
return "Please select atleast one";
}
$sql .= $id != 'x' ? " s.id={$id} LIMIT 1" : " s.id IN ({$slctd_samples_str}) GROUP BY s.id";
$vldbresult = \DB::connection('live_db')->select($sql);
if (\Request::has('pdf')) {
$s_arr = $id != 'x' ? [$id] : explode(",", $slctd_samples_str);
$sql = "INSERT INTO vl_facility_downloads (sample_id, downloaded_by, downloaded_on) VALUES";
foreach ($s_arr as $smpl) {
$sql .= "({$smpl}, '" . \Auth::user()->email . "', '" . date('Y-m-d H:i:s') . "'),";
}
$sql = trim($sql, ',');
\DB::connection('live_db')->unprepared($sql);
$pdf = \PDF::loadView('results.pdfresults', compact("vldbresult"));
return $pdf->download('vl_results_' . session('facility') . '.pdf');
//return \PDF::loadFile('http://www.github.com')->inline('github.pdf');
}
return view('results.result', compact("vldbresult", "printed"));
}
示例5: rqHas
/**
* Check if specified element exists in a request.
*
* @param $name
*
* @return bool
*/
function rqHas($name)
{
if (Request::has($name)) {
return true;
}
return false;
}
示例6: process
public function process(Request $request)
{
// Ajax-validation is only possible, if the _formID was submitted (automatically done by the FormBuilder).
if (\Request::has('_formID')) {
// The FormBuilder should have saved the requestObject this form uses inside the session.
// We check, if it is there, and can continue only, if it is.
$sessionKeyForRequestObject = 'htmlBuilder.formBuilder.requestObjects.' . \Request::input('_formID');
if (Session::has($sessionKeyForRequestObject)) {
// Normally we assume a successful submission and return just an empty JSON-array.
$returnCode = 200;
$return = [];
// We instantiate the requestObject.
$formRequest = FormBuilderTools::getRequestObject(Session::get($sessionKeyForRequestObject));
// We instantiate a controller with the submitted request-data
// and the rules and messages from the requestObject.
$validator = Validator::make(\Request::all(), $formRequest->rules(), $formRequest->messages());
// Perform validation, extract error-messages for all fields on failure, put them inside a $return['errors']-array, and return status code 422.
if ($validator->fails()) {
$errors = [];
foreach (array_dot(\Request::all()) as $fieldName => $fieldValue) {
$fieldErrors = FormBuilderTools::extractErrorsForField($fieldName, $validator->errors()->getMessages(), \Request::all());
if (count($fieldErrors) > 0) {
$errors[FormBuilderTools::convertArrayFieldDotNotation2HtmlName($fieldName)] = $fieldErrors;
}
}
$return['errors'] = $errors;
$returnCode = 422;
}
return new JsonResponse($return, $returnCode);
}
}
}
示例7: index
public function index()
{
Cache::loadPage('', 30);
$inputData = array();
$postid = 0;
Model::loadWithPath('post', System::getThemePath() . 'model/');
if (!($match = Uri::match('post\\/(.*?)\\.html$'))) {
Redirect::to('404page');
}
$friendly_url = addslashes($match[1]);
$loadData = Post::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'"));
if (!isset($loadData[0]['postid'])) {
Redirect::to('404page');
}
$inputData = $loadData[0];
if (Request::has('btnComment')) {
try {
sendComment($loadData[0]['postid']);
$inputData['commentAlert'] = '<div class="alert alert-success">Send comment success.</div>';
} catch (Exception $e) {
$inputData['commentAlert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>';
}
}
$postid = $loadData[0]['postid'];
$listTag = PostTags::renderToLink($postid);
$inputData['listTag'] = $listTag;
$inputData['listComments'] = Comments::get(array('where' => "where postid='{$postid}' AND status='1'", 'orderby' => "order by postid desc"));
Post::upView($postid);
System::setTitle(ucfirst($loadData[0]['title']));
$keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords();
System::setKeywords($keywords);
self::makeContent('post', $inputData);
Cache::savePage();
}
示例8: index
public function index()
{
$books = Book::with('Author')->where(function ($query) {
$min_price = \Request::has('min_price') ? \Request::get('min_price') : null;
$max_price = \Request::has('max_price') ? \Request::get('max_price') : null;
$authors = \Request::has('authors') ? \Request::get('authors') : [];
if (isset($min_price)) {
$query->where('price', '>=', $min_price);
}
if (isset($max_price)) {
$query->where('price', '<=', $max_price);
}
if (isset($authors)) {
$query->where(function ($q) {
$input_authors = \Request::has('authors') ? \Request::get('authors') : [];
// $books_all = \App\Book::with('Author')->get();
//перебираем все чекнутые боксы
foreach ($input_authors as $input_author) {
// автор == выборка из авторов где Ид = чекнутому боксу. Первый
$author = \App\Author::with('books')->where('id', '=', $input_author)->first();
// выборка внутри выбранного автора по книгам
foreach ($author->books as $author_book) {
//запрос Айди книги == айди книг у этого автора
$q->orWhere('id', '=', $author_book->id);
}
}
});
}
})->paginate(2);
$authors_list = \App\Author::all();
return view('books.list', compact('books', 'authors_list'));
}
示例9: save
public function save()
{
$name = $this->name();
if (!\Request::has($name)) {
\Request::merge([$name => 0]);
}
parent::save();
}
示例10: save
public function save()
{
$name = $this->name();
if (\Request::has($name)) {
\Request::merge(array($name => password_hash($this->value(), PASSWORD_BCRYPT)));
parent::save();
}
}
示例11: check
public function check(JSnapCommander $jsnap)
{
if (\Request::has('checkHostname')) {
$result = $jsnap->snapCheck(\Request::get('checkHostname'));
return ['error' => 0, 'result' => $result];
}
return ['error' => 1, 'html' => 'Must designate a hostname, presnap, and postsnap'];
}
示例12: searchAction
/**
* @param Request $request
*
* @return Response
*/
public function searchAction(Request $req)
{
$typeFilter = $req->get('type');
$tagsFilter = $req->get('tags');
if ($req->has('q') || $typeFilter || $tagsFilter) {
$solarium = new SolariumClient('localhost:8080');
$select = $solarium->createSelect();
// filter by type
if ($typeFilter) {
$filterQueryTerm = sprintf('type:%s', $select->getHelper()->escapeTerm($typeFilter));
$filterQuery = $select->createFilterQuery('type')->setQuery($filterQueryTerm);
$select->addFilterQuery($filterQuery);
}
// filter by tags
if ($tagsFilter) {
$tags = array();
foreach ((array) $tagsFilter as $tag) {
$tags[] = $select->getHelper()->escapeTerm($tag);
}
$filterQueryTerm = sprintf('tags:(%s)', implode(' AND ', $tags));
$filterQuery = $select->createFilterQuery('tags')->setQuery($filterQueryTerm);
$select->addFilterQuery($filterQuery);
}
if ($req->has('q')) {
$escapedQuery = $select->getHelper()->escapeTerm($req->get('q'));
$select->setQuery($escapedQuery);
}
$paginator = new Pagerfanta(new SolariumAdapter($solarium, $select));
$paginator->setMaxPerPage(15);
$paginator->setCurrentPage($req->get('page', 1), false, true);
if ($req->isXmlHttpRequest()) {
try {
return $this->render('ProductBundle:Search:list.html.twig', array('products' => $paginator->getResults(), 'noLayout' => true));
} catch (\Twig_Error_Runtime $e) {
if (!$e->getPrevious() instanceof \Solarium_Client_HttpException) {
throw $e;
}
return new JsonResponse(array('status' => 'error', 'message' => 'Could not connect to the search server'), 500);
}
} else {
return $this->render('ProductBundle:Search:search.html.twig', array('products' => $paginator->getResults()));
}
}
return $this->render('ProductBundle:Search:search.html.twig', array('noLayout' => $req->isXmlHttpRequest()));
}
示例13: getIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
$links = Link::sort()->get();
if (\Request::has('key')) {
$key = \Request::input('key');
$links = Link::where('title', 'like', '%' . $key . '%')->sort()->get();
}
return view('admin.link.index', compact('links'));
}
示例14: getIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function getIndex()
{
$feedbacks = FeedBack::paginate(15);
if (\Request::has('key')) {
$key = \Request::input('key');
$feedbacks = FeedBack::where('title', 'like', '%' . $key . '%')->paginate(15);
}
return view('admin.feedback.index', compact('feedbacks'));
}
示例15: destroy
public function destroy(Post $post)
{
if (\Request::has('id')) {
Post::destroy(\Request::input('id'));
return ['result' => true];
}
$post->delete();
return redirect('dash/post')->with('message', 'Post was delete success.');
}