I installed PyroCMS and am extending it to make it into a Learning Management System (LMS) where only logged-in users can view the pages, and the pages also only begin to be viewable a variable number of days after a user enrolls in the course.
(I.e., Module 1's Lesson 1 may unlock and be visible immediately, but Lesson 2 could be configured to be hidden until 1 day later, and Lesson 3 might become visible X days later, etc.)
How I achieved this was by writing a Laravel package with this migration:
Schema::table('pages_pages', function (Blueprint $table) {
$table->string('drip_delay')->nullable()->after('str_id');
});
I then created a DrippablePagesServiceProvider class with this in the boot() function:
$this->app->bind('Anomaly\PagesModule\Http\Controller\PagesController', 'me\DrippablePages\PagesController'); //https://laravel.com/docs/5.6/container#binding
I designed my custom PagesController to show a special view whenever the logged-in user is trying to access a page too early. This functionality is all working totally fine.
But instead of editing the drip_delay field directly in the database like I've been doing, I'd prefer to be able to edit right alongside the other fields at the /admin/pages/edit/4 URL.
I'm pretty sure I need to override various parts of PagesModule, such as PageEntryFormSections (doc). And I think I have that working.
But when stepping through with Xdebug, I see that the PageModel that gets looked up at this line (via dependency injection?†) in edit() within Http\Controller\Admin\PagesController still doesn't show my new drip_delay field.
How can I override PageModel or do whatever I need to do so that it shows the drip_delay field in this Admin panel view?
† Laravel docs about container and controllers imply this.
To override a model first you need a new one which extends a model you want to override:
Then inside the
ServiceProvideryou need to bind it reversed:That's all. Good luck ))