Support the ongoing development of Laravel.io →
posted 11 years ago
Views

I have a macro inside a page.

@extends('mobilemaster')


@section('content')
   
{{Form::macro('date', function()
{
    return ' <input type="date" data-clear-btn="true" name="date-2" id="date-2" value="">';
}); }}
   

But now i want to use that macro on another 10 pages too. so i thought i'd place that macro code inside the mastermobile page. But when i do that laravel says: 'Method date does not exist'.

So i have to copy and paste the macro 10 times in every view i use a the date macro?

Last updated 3 years ago.
0

What I normally do is create a macros.php in the app folder and include it within app\start\global.php by adding

require app_path().'/macros.php';
Last updated 3 years ago.
0

Nice :D Worked like a charm.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

JeffreyR jeffreyr Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.