I want to use the cknow/laravel-money
package in pretty much every page in my app. I thought a tidy way to do this would be to import the class in the parent blade. However, child templates do not seem to have access to the imported class.
I've tried using standard <?php ?>
tags and @php @endphp
directives.
app.blade.php
@php
use Cknow\Money\Money;
@endphp
<title>{{ config('app.name') }}</title>
</head>
<body>
@include('inc.navbar')
@include('inc.flashmessages')
<div class="container">
@yield('content')
</div>
</body>
</html>
show.blade.php
<div class="card-footer text-muted">
{{ Money::GBP($item->price) }}
</div>
This throws.
"Class 'Money' not found."
Whereas including the same use statement in the child class works as expected.