php - How to pass parameters from one view to another view? -


shirt.blade.php:

@extends('layout.main') @section('title','shirts')   @section('content')  <div class="row">      @forelse($shirts->chunk(20) $chunk)     @foreach($chunk $shirt)     <div class="small-3 columns">         <div class="item-wrapper">             <div class="item2">                 <div class="img-wrapper">                     <a href="{{route('cart.additem',$shirt->id)}}"  class="button expanded add-to-cart">                         <span title = "to add cart directly">add cart </span>                     </a>                     <a href="#">                         <img src="{{url('images',$shirt->image)}}"/>                     </a>                 </div>                 <a href="{{url('/shirt.$shirt->id')}}">                     <h3>                         {{$shirt->name}}                     </h3>                 </a>                 <h5>                     ${{$shirt->price}}                 </h5>                 <p>                     {{$shirt->description}}                 </p>                 </div>             </div>         </div>         @endforeach         @empty         <h3>no shirts</h3>         @endforelse     </div>     <br> 

i passing $shirt->id parameter

</div> <a href="{{url('/shirt.$shirt->id')}}"> <h3>     {{$shirt->name}} </h3> 

this controller passing id.named frontcontroller.php

public function shirt($id) {     $shirt = product::all();     return view('front.shirt', compact('shirt')             ->with('id' => '$id');     } } 

how can pass id view shirts.blade.php view shirt.blade.php

please help.thanks in advance

you should try this:

change blade file code , controller code like

<a href="{{url('/shirt', $shirt->id)}}">     <h3>        {{$shirt->name}}     </h3>    public function shirt($id){     $id = $id;     $shirt = product::all();    return view('front.shirt', compact('shirt','id'); } 

updated answer

change shirts.blade.php code

<a href="{{url('shirt', $shirt->id)}}">      <h3>         {{$shirt->name}}     </h3> </a> 

to

<?php print('<pre style="color:red;">');   print_r($shirt->id);   print('</pre>');   exit; ?>  <a href="{{ route('shirt', [$shirt->id]) }}">      <h3>         {{$shirt->name}}     </h3> </a> 

hope work !!!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -