Where do I put Laravel 4 helper functions that can display flash messages?

后端 未结 8 897
孤街浪徒
孤街浪徒 2021-02-12 14:07

I\'ve written a simple display_messages() function that will search Session::get(\'errors\') for flash data and echo it to the screen.

Where do

8条回答
  •  故里飘歌
    2021-02-12 14:43

    As Usman suggested,

    • create a file /application/libraries/demo.php
    • define a class Demo() { inside it
    • call the function like so: {{ Demo::display() }}

    Works because libraries and models are autoloaded in start.php line 76. I believe that filenames must match Classnames (note capital).

    print_r($message)
    "; } }

    Can't quite figure out why I had a problem using the classname Common, there may be a conflict (you could define a namespace if this were important)...

提交回复
热议问题