Which id?
$x = YourModel::find(1);
$length = $x->length;
$width= $x->width;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
this is my db
id length width
1 300 400
2 350 500
3 430 125
4 980 410
I need that when I go to create.blade.php and click on select id, the length and width of this id would appear
Did you mean to do this?
<select name="product_id" style="width: 170px" class="form-control" >
foreach($products as $product)
<option value="{{$product->id}}"> {{$product->width}} - {{$product->length}} </option>
@endforeach
And in store()
$product = Product::find($request->input('product_id' );
Product::create([
'length' => $product->length,
'width' => $product->width,
'area'=> $product->length * $product->width
]);
Please or to participate in this conversation.