Laravel, connection between the back office and the front office

Asked

Viewed 49 times

-1

Good Afternoon, I’m doing a small project with Back Office and Front Office in Laravel. In the back office, all the data that is then presented on the front office is created, that is, the news that users can consult is created in the back office and then inserted in a specific layout. I can’t figure out how to send the news to the layout, can anyone explain to me?

1 answer

0

It’s very simple, as long as you have the instruction to print a view in your layout: @yield('content'), at the end of your controller’s method you simply return:

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

class NoticiasController extends Controller
{
    public function noticias()
    {
        $noticias = [];//aqui você retorna as noticias do model
        return view('noticias', compact('noticias'));
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.