0

In my project, I got many forms, so I've decided to specify each one with an iscription field, for exemple: Kids' form => <input = 'hidden' name = 'inscripted_in' value = 'kids'>. I want to set each one with a default value, but whenever I sign in, I get this error message: SQLSTATE[HY000]: General error: 1364 Field 'inscripted_at' doesn't have a default value Although when I go to Laravel Debug, I still get the inserted constant value, what's the problem?

This is one of my forms

                <div class="InputBox">
                    <input type="hidden" name="inscripted_at" value="Adults">
                    <input type="hidden" name="status" value="pending">
                </div>

my controller:

public function store(Request $req)
   {
    $this->validate($req,[
        'name' => 'required|max:120',
        'surname' => 'required|max:120',
        'job' => 'required|max:120',
        'day' => 'required',
        'month' => 'required',
        'year' => 'required',
        'hobby' => 'required|max:120',
        'help' => 'required|max:120',
        'place' => 'required|max:120',
        'residence' => 'required|max:120',
        'email' => 'required|email|unique:users',
        'photo' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        'scholar_year' => 'required|max:120',
        'tel' => 'required|regex:/(05)[0-9]{8}/',
        ]);

        Chababounauser::create($req->all());

      
       return redirect()->route('chababounausers.index')
                       ->with('success','chababouna User inserted successfully.');
   }

2 Answers 2

1

Check the fillable property of the Chababounauser model.

P.S.: Please, don't put spaces in HTML between attribute name and it's value.

Sign up to request clarification or add additional context in comments.

1 Comment

I've cheked it and added the missing fields, but I still get the error.
0

Isn't 'inscripted_at' a default column in the database giving the date of inscription ? If so, you can't default a value to that kind of output.

2 Comments

it's not the date, it represents the field of the inscription.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.