문제

I have custom macro such as *image_link* and I'm using that into route.php how to register this macro without defining this file? For example I must create a new model into model directory such as Helpers?

or how to define that into core laravel?

HTML::macro('image_link', function($url = '', $img='img/', $title ='' ,$alt='', $param = false, $active=true, $ssl=false)
{
    $url = $ssl==true ? URL::to_secure($url) : URL::to($url);  
    $img = HTML::image($img,$alt);
    $link = $active==true ? HTML::link($url, '#', $param) : $img;
    $link = str_replace('#', $img.$title ,$link);
    return $link;
}); 

올바른 솔루션이 없습니다

다른 팁

  1. Define a app/lib folder.
  2. Then register this folder to be autoloaded by Laravel.
  3. Create a new class app/lib/helper.php

A similar process is further explained in this question. You just need to update your namespaces accordingly and replace that class with your class containing your helper methods.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top