I want to add a variable( in my case it is called $document) from my database to a URL asset directory in the view of my blade file to enable a user to view the image in the web browser. An example is as follows;
// MyController File
// the variable $code is a parameter I'm accepting from the web.php route file for
// the function show() to help process the assignment value of $data['document'] without issues
public function show($code)
{
// NB: I am passing the document as an array list item of $data as below, so I can mention it as
// a variable in the blade view file
// $data['document']
$data['document'] = Auth::user()->documents->where("code", $code)->first();
return view("documents.show", $data);
}
// Blade View File
<div class="my-class" style="background: url() no-repeat center top; background-size: cover;">
</div>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire