0

I am storing form input in laravel, and almost everything works fine the other form inputs are correctly stored but not my color codes.

The names are correct otherwise i would get an error while updating and storing. Here is what i have.

laravel db table columns

 $table->string('color_code_1')->default('#006661');
 $table->string('color_code_2')->default('#006661');
 $table->string('color_code_3')->default('#006661');

form values send to api

 color_code_1: #006661
 color_code_2: #006664
 color_code_3: #006661

Controller storing values

public function update(Request $request, $id)
{
    $input = $request->all();

    $user->cases()->whereId($id)->first()->update($input);

    return redirect('/admin/cases');
}

This is working fine for all my other values but these three values just wont change in the db.

Maybe it has something to do with their hex values but i couldnt figure it out.

Does someone have an idea? Thanks in advance!

5
  • 1
    add this column to fillable array Commented May 9, 2019 at 6:52
  • 4
    Are the color_code_* columns added to the $fillable array in the model? Commented May 9, 2019 at 6:52
  • Where does $user come from? Commented May 9, 2019 at 6:53
  • Well i guess that fixed it lol, thanks a lot both of you! Commented May 9, 2019 at 6:53
  • Fine. Glad we could help! Commented May 9, 2019 at 6:59

1 Answer 1

1

Solution edit the fillable in my model

   protected $fillable = [
        'color_code_1',
        'color_code_2',
        'color_code_3',
      ];
Sign up to request clarification or add additional context in comments.

Comments

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.