Thursday, March 16, 2017

Laravel - operators dont work

Im new to laravel, and i have been learning a few more things. But now im getting a error that i have never seen in plain php. Some operators that i test at the function catalog dont work, and other do work. Only the =, != and <> work while the <, >, >= and <= dont. It gives: "Illegal operator and value combination"; and also: ->where('Price', '(operator)', null). I have tried "wherenull" but doesnt work. Can anyone help me out on this one? Im using laravel 5.4.

the code:

controller (in this case i have placed ">=" it doesnt work)

function catalog(Request $abc) {
    $categoryesc = $abc->categoryesc;
    $priceesc = $abc->priceesc;
    $categories = DB::table('categories')->pluck('Category', 'id');
    $robots = DB::table('robots')->where('Category_id', $categoryesc)->where('Price', '>=', $priceesc)->get();
    return view('catalog', compact('robots', 'categories'));
}

view

@extends('layouts.layout')
@include('header')

<main>
<div>Choose the category</div>
{!! Form::open(array('method' => 'GET')) !!}
    {!! Form::select('categoryesc', $categories) !!}
    
    {!! Form::submit('Ok') !!}
{!! Form::close() !!}

<div>Choose the model</div>
<b>On this page ( robots)</b>

<div id="area1">
@foreach($robots as $robot)
  {!! Form::open(array('action' => 'RobotController@orders', 'method' =>  'GET')) !!}
  {!! Form::hidden('modelesc', $robot->Model) !!}
  {!! Form::submit($robot->Model) !!}
  {!! Form::close() !!}
@endforeach
</div>

</main>



via Adato

Advertisement