0

I understand how Laravel works but taking a look at Octobercms which is built on Laravel, I believe and understand that plugin when created can be imported and used in multiple static pages in multiple pages, but I still cannot get to understand when and how someone needs to use routes.php in the plugin.

Please help me understand by giving me a use case study. I can't just get this in the documentation.

halfer
  • 19,824
  • 17
  • 99
  • 186
Abel Agoi
  • 131
  • 2
  • 12
  • You can define your web services in the `routes.php` file of your plugin. – B Faley Apr 15 '17 at 19:01
  • 2
    Why do you need to "understand when and how someone needs to use routes.php"? When you need to use it, you'll know. Are you trying to ask a more specific question like "How can I effectively use routes.php" or maybe "what are good examples of routes.php being utilized within a plugin"? – LukeTowers Apr 17 '17 at 04:26

1 Answers1

1

Route.php is useful to create REST API and external entry point to your application

Exemple from octobercms Task scheduling not working

use Route;

Route::get('/yourprefix/delete_users', function () {
DB::connection('mydb')->table('u')->whereRaw('u.created_at <= NOW() - INTERVAL 1 DAY')->where('is_activated','=',0)->delete();
});

Create an entry point for an http cron job on a server without command line access.

Community
  • 1
  • 1