jeudi 3 septembre 2015

Laravel 5.1 - How to load content from database for Master Page

I'm making an administrable website in Laravel. I have a custom class that loads the content of a page / widget from a database and returns HTML.

/**
 * Loads a page content from the database
 * 
 * @param Id of the page, it can be a number or class constant
 * @return html
 */
public function pageContent($id)
{
    $content = DB::table('pages')->where('id', '=', $id)->first();
    return $content->content;
}

Let's say the website administrator put in that page something like:

"All Rights reserved, blablabla 2015, Contact Us: 488 889 77 88"

And I want it to appear in the website footer. Some of my master page code is.

<body>

    @include('layouts.mainmenu')

    @yield('body')

    <div class="footer">
        {{ I WANT TO HAVE THE FOOTER FROM THE DATABASE HERE! }}
    </div>

    <script src="http://ift.tt/1LdO4RA"></script>
    <script src="{{ asset('js/bootstrap.min.js') }}"></script>
    <script src="{{ asset('js/main.js') }}"></script>

    @yield('bottom-js')

</body>



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1fYobe3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire