ali_254 Posted June 6, 2021 Share Posted June 6, 2021 (edited) hi... i create two table in laravel and I created a "join" operation between them. controller file: class FlightController extends Controller { public function function1(Request $request,$id ){ $data1=Flight::find($id); $a=$data1->FlightComment(); dd($a); return view('audi')->with('id',$id)->with('a',$a); } } Variable "A" is an array, how can I display it in file "blade.php"? thanks Flight table: FlightComment: Edited June 6, 2021 by ali_254 Quote Link to comment Share on other sites More sharing options...
requinix Posted June 6, 2021 Share Posted June 6, 2021 https://www.google.com/search?q=how+to+use+blade+templates+in+laravel 1 Quote Link to comment Share on other sites More sharing options...
ali_254 Posted June 6, 2021 Author Share Posted June 6, 2021 (edited) 3 hours ago, requinix said: https://www.google.com/search?q=how+to+use+blade+templates+in+laravel ok thanks , but i have a problem.. i add this code in controller but variable $data1 in file blade.php Cannot be identified class FlightController extends Controller { public function function1(Request $request,$id ){ $data1=Flight::find($id); return view('audi')->with('id',$id)->with('a',$data1); } } error: (2/2) ErrorException Undefined variable: data1 (View: C:\wamp64\www\Amozesh_php\shoplaravel\resources\views\audi.blade.php) file blade.php: @extends('layout.master') @section('content') <h2>ali niknami</h2> @endsection {{ $data1 }} <form action="/users/insert" method="post"> {{csrf_field()}} <input type="text" name="title" id="title"> <br> <input type="text" name="title2" id="title2"> <br> <input type="text" name="title3" id="title3"> <input type="submit" value="register"> </form> Edited June 6, 2021 by ali_254 Quote Link to comment Share on other sites More sharing options...
requinix Posted June 6, 2021 Share Posted June 6, 2021 ->with('a',$data1) The first argument to with() is the name of the variable you want to create inside the view. The second one is its value. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.