laravel - How can I reach base.php functions via my view files? -
i pass array/object database view file this:
view::make('home.announcements') ->with('announcements', announcements::all()); when passed view file, contains integers, like:
$announcements[$k]->month //output 05 i need call function inside base.php convert 05 "may", "may" result in view.
<span> {{ $this->convertmonthtostring($announcements[$k]->month) }} </span> //output: <span>may</span> i know can pass directly ->with that's not i'm asking. don't want pass additional information using additional ->with's.
i want views handle basic output functions.
how can this?
you need create function in 'announcements' model called:
public function get_fullmonth() { return date('f', strtotime($this->get_attribute('month'))); } call in in view as:
@foreach ($announcements $item) <span>{{$item->fullmonth}}</span> @endforeach
Comments
Post a Comment