samedi 30 juillet 2016

Save SQL queries and execute them later in Laravel 5.2?

I have two types of users in my Laravel application and I'd like them to have different permissions.

I want the admin to be able to create, retrieve, update and delete some objects stored on my database. And the common user to be able to only retrieve these objects. But, I'd like to have them ask for permission on the other actions, and then, have an admin execute them. I imagined the common users going through almost the whole proccess, but near the end, instead of executing the query, the application should save it in the "requests" table.

The "requests" table would have the following collumns:

  • id int auto_increment
  • user_id int (would be the id of the user that requested the action)
  • date date (so the admin knows when the request was made, I would just get the current time when the user tries to execute)
  • query string (this would be the query generated by laravel)

My doubts are, is it possible to save the query in Laravel before it is executed? If so, how do it? Also, after it's on my table, how can I run it later?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire