jeudi 26 décembre 2019

right way to pass a boolean from controller to store a form data

i'm new to laravel and don't know what i did wrong. i'm having this "Symfony\Component\Debug\Exception\FatalThrowableError syntax error, unexpected '='" whenever i try to submit my form.

this is in my create.blade.php

<div class="form-check">
  <input class="form-check-input" type="checkbox" value="1" id="#is_available?" name="is_available?">
  <label class="form-check-label" for="is_available?">
    Is this available and ready to be rented?
  </label>
</div>

and in my CarsControllers.php

public function store(Request $request)
{
    $car = new car;

    $car->car_brand = $request->car_brand;
    $car->car_name = $request->car_name;
    $car->description = $request->description;
    $car->car_type_id = $request->car_type_id;
    $car->image_location = '';
    $car->is_available? = $request->is_available?;


    $car->save();

    return redirect('/selections');

}

The rest is okay except with that boolean. i don't know what to do. my column name is 'is_available?' to i have to change it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire