This must be really simple, but since I’m new to Laravel, I’m having difficulties on finding this feature on documentation or in stackoverflow.
I’m going to try to build a very simple example to try to show what I want.
Let’s say I have a file called data.blade.php
@php
$myVariable = 'xyz';
@endphp
Then, I have my layout template file, called: home.blade.php
@extends('data.blade')
@section('content')
@php
echo $myVariable;
@endphp
@endsection
When I try to do this, it returns me an error:
Undefined variable $myVariable (etc)
How can I use a variable defined in another blade file? I used extends to exemplify, but I´m not sure if that is the right architecture.
Can anyone point me to the right way of accomplishing this?
Thanks!