Jump to content

How to display a variable in the "blade.php" file


ali_254

Recommended Posts

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:

flights.thumb.jpg.936d345fe0227a02ebd6da7da06ef501.jpg

 

 

FlightComment:

flight_comments.thumb.jpg.d6c0e798fa4938e2c77d1746996b7028.jpg

Edited by ali_254
Link to comment
Share on other sites

3 hours ago, requinix said:

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 by ali_254
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.