I'm slowly starting to come to grip with Laravel but keep having little issues doing basic things.
So this is what I have at the moment
A function and a function that is called by my route
both in my webcontroller.php
// Function for printing out copyright year
function copyright_info($begin_year = NULL)
{
date_default_timezone_set('Europe/London');
if(empty($begin_year) || $begin_year == date('Y'))
echo date('Y');
else
echo $begin_year." - ".date('Y');
}
// function being called by route.php to get Restaurant Page
public function restaurant () {
$cookie = Cookie::get("basket");
return view('pages.restaurant', ['basket' => $cookie]);
}
Now all the first function does is print out something like 2013-2015
once the year is provided.
So I should be able to do something like this
public function restaurant () {
// use the function and get copyright year
$year = copyright_info('2013')
$cookie = Cookie::get("basket");
// pass data to the view including the year we just created
return view('pages.restaurant', ['basket' => $cookie, 'year' => $year]);
}
Now in my restaurant.blade.php
file, I'm including my footer in my includes
folder that is generic to all my pages like this @include('includes.footer')
. Now the footer is what actually contains a div
that requires the $year
I have passed to the restaurant
view. in my footer.blade.php
I have this
<p style="font-size: 0.9rem">Copyright © {{ $year }} | xxx.com Limited</p>
Now I would assume that when I pass data to restaurant
and footer
is included in restaurant
the data will apply to footer
when it gets included in restaurant
but that doesn't happpen.
Any guidance appreciated
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1VoFXGW
via IFTTT
Aucun commentaire:
Enregistrer un commentaire