i have table "food" has column food_id food id of each food. want show foods according food_id.
my controller is:
public function index() { $details= food::all(); return view('details.index', compact('details')); } public function show($food_id) { $detail=food::findorfail($food_id); return view('details.show', compact('detail')); }
my routes are:
route::get('details', 'detailscontroller@index'); route::get('details/{food_id}', 'detailscontroller@show');
index.blade.php:
@extends('layouts.app') @section('content') <h1>details</h1> <hr/> @foreach($details $detail) <detail> <h2> <a href="/details/{{$detail->food_id}}">{{$detail->foodname}} </a> </h2> </detail> @endforeach @endsection
show.blade.php:
<h1 align="center">{{$detail -> foodname}}</h1> <detail> <h3><p>foodtype:</h3><h4>{{$detail->foodtype}}</h4></p>
and welcome.blade.php:
<button type="submit" onclick="window.location='http://localhost:8000/details'" style="font-size:14px; width: 230px; height: 30px; background-color: #00a30c; color: white; font-style: italic; text-align: center; font-size: 15px; margin: 0 auto;"> {{ $food[$i]->foodname }} <i class="fa fa-chevron-circle-right"></i></button>
my problem have button image of food on welcomepage , want when click button,it shows me food details based on food_id. when click on button welcomepage shows me details page again food items shown shown in screen:
then clicking on food items shows me datails of food as:
but want when click food item welcome page shows me page without showing screen 1 page.
Comments
Post a Comment