Level 28
Route::get('/', function () {
return view('prodview');
});
You display the prodview without passing it the product variable.
please tell me where i going wrong
ProductController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\product;
class ProductController extends Controller
{
public function show()
{
$product=product::get();
return view('prodview',compact('product'));
//return redirect('prodview');
}
}
prodview.blade.php
<div class="content">
<form method="post" action="{{url('/')}}/store1" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" name="MAX_FILE_SIZE" value="10485760">
<table class="table table-striped">
<td><select name="p_id" class="form-control">
@foreach($product as $prod)
<option value ="{{$prod->p_id}}">{{$prod->p_name}}</option>
@endforeach
</select></td>
</table>
</form>
<br><hr>
</div>
web.php
Route::get('/', function () {
return view('prodview');
});
Route::get('show','ProductController@show');
If you have problem with url then type as like below in your command promt and show the result here,
php artisan route:list
with that use below query us all() instead of get(),
$product=product::all();
Please or to participate in this conversation.