3

I have built a custom User Permission system into my bosses company app which includes a webcam timeclock for employees as well as pages to run reports from the database and many other company related apps and pages.

The app is built with PHP and Laravel.

In my Laravel routes file I have some sections setup to require Admin user authentication and others to just require and logged in user.

Now that we are expanding the app and I have built a permissions system that will allow setting page access on a per page and per user basis. I need to do away with my Route authentication requirements and instead setup permissions per page using my new permissions settings for each user.

So my question is, how can I go about auto detecting every page.route in the app so that on my permissions page I can show an entry for every page of the app?

In the image below, every page was manually added to a database table. I now need to instead auto-detect all routes in the app.

enter image description here

JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • I might of posted this too soon. Now I see there is a `getRoutes()` method available that I need to look into – JasonDavis Jul 10 '15 at 18:01

1 Answers1

2

I posted this question too soon. I now see there is a getRoutes() method

Code from Answer https://stackoverflow.com/a/23673282/143030

Route::get('routes', function() {
$routeCollection = Route::getRoutes();

echo "<table style='width:100%'>";
    echo "<tr>";
        echo "<td width='10%'><h4>HTTP Method</h4></td>";
        echo "<td width='10%'><h4>Route</h4></td>";
        echo "<td width='80%'><h4>Corresponding Action</h4></td>";
    echo "</tr>";
    foreach ($routeCollection as $value) {
        echo "<tr>";
            echo "<td>" . $value->getMethods()[0] . "</td>";
            echo "<td>" . $value->getPath() . "</td>";
            echo "<td>" . $value->getActionName() . "</td>";
        echo "</tr>";
    }
echo "</table>";
});
Community
  • 1
  • 1
JasonDavis
  • 48,204
  • 100
  • 318
  • 537