F
F
fso2016-06-27 18:49:04
Laravel
fso, 2016-06-27 18:49:04

How to properly implement dynamic routing in Laravel?

Hello Laravel Experts!
I have been wanting to start using this convenient framework for a long time, but one circumstance is holding me back: I don’t see beautiful ways to implement dynamic routes so that they can be loaded from the database.
Let me explain: I'm looking for a way to transfer a project from a closed framework, where routing is built around a multidimensional array (that is, the tree of the site's pages lies in an array). This is very convenient, because it makes it easy to implement the inheritance of any page properties down the tree - a simple RecursiveArrayIterator is enough.
I would like to transfer this approach to laravel, that is, to have the inheritance of page properties from parent to child (including access rights) and store all this in the database, since the site is managed from the admin panel (creating the entire tree, assigning access rights, templates to pages, etc. ).
Tell me where to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DieZz, 2016-06-27
@DieZz

I did this:
Where the controller got the required page from the database. More or less like this:

class PageHandlerController extends Controller
{
    public function handle($page)
    {
        $page = CustomPage::where('url', $page)->first();

        if (!$page) {
            abort(404);
        }

        // тут делаем все что нам угодно
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question