Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Laravel Shareable Models Package
Sep 06, 2017 @ 11:56:26

On the Laravel News site there's a new post highlighting a shareable models package that allows for the creation of dynamic routes for models that are shared.

My initial use case was giving certain non-admin user access to a certain resource that is usually only accessible through the admin interface.

Instead of mucking around with special permissions I created this method to create a completely new link from the resource that I wanted to share, that I could then treat like any other route in my application. So a separate controller and separate views. In that route, you can then simply only expose the functionality that you want (make it read-only for example or only show certain fields).

The package allows the automatic creation of "shareable links" to models including functionality that allows for password protection and expiration times. A code example is included showing how to set up a link to an article entry and what the result looks like (a JSON response).

tagged: laravel package sharable model link spotlight

Link: https://laravel-news.com/laravel-shareable-models-package