Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bart's avatar

Glad to hear that you got it now. Everyone of us knows the human brain freezing bug. Thats why such a great forum like Laracasts is so amazing and enthusiasts help each other :)

I will go home now but afterwards I will check your latest posts so that we can get it working!

1 like
theUnforgiven's avatar

Basically you see this:

'size' => string '6' (length=1)
  'colour' => string 'Black' (length=5)
  'stock' => string '2' (length=1)
  'size_1' => string '10' (length=2)
  'colour_1' => string 'Cream' (length=5)
  'stock_1' => string '3' (length=1)

has two different set of values correct? I need to them add both values to the db with the same product_id but it inserting the first size, colour, stock values twice.

like so - http://cl.ly/image/1A3V3m0X3i2b When in actual fact it should do this - http://cl.ly/image/1w3O373F0z03

And i've been trying to do it like this:

 if (Input::get('size') ?: null) {
            $option = new Options;
            $option->product_id = '1';
            $option->size = Input::get('size');
            $option->colour = Input::get('colour');
            $option->stock = Input::get('stock');
            $option->save();
        }
        if (Input::get('size_1') ?: null) {
            $option = new Options;
            $option->product_id = '1';
            $option->size = Input::get('size');
            $option->colour = Input::get('colour');
            $option->stock = Input::get('stock');
            $option->save();
        }

has i though using new Options; twice would insert twice as two different values.

arabsight's avatar
Level 10

you're repeating the same values in both records you need to do this for the second record:

$option->size = Input::get('size_1');
$option->colour = Input::get('colour_1');
$option->stock = Input::get('stock_1');
1 like
theUnforgiven's avatar

So based on @arabsight said, now how do I show the value within my edit form as the selected value then show the rest of the list from the relevant table, and the rest of the options from the colour's table like I did before like this

Colours::lists('name', 'name')
bart's avatar

So everything works now? Do you use the normalized table structure?

bart's avatar

What exactly is the problem you have with the form?

theUnforgiven's avatar

I need it to populate what comes from the database then also show the reminder of the list from the colour, size tables.

Previous

Please or to participate in this conversation.