jeudi 2 août 2018

how to display name from database in laravel

i want to display data from my database

controller

public function generatePDF(Request $request)
{
    $id = Auth::user()->id;
    $name = User::select("NAME")->where("id", $id)->get();
    $pdf = PDF::loadView('generatePDF', ['name'=>$name]);
    return $pdf->stream('generatePDF.pdf');
}

blade

<h2></h2>

result

[{"NAME":"name_from_database"}]

can i display without [{"name":}], so just the value of data (name_from_database) ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire