framework
framework copied to clipboard
Override vanilo controllers
I’m using vanilo in a project I’m working on even though I realise you do not have the 1.0 yet.
I’ve had to modify a method in a controller in vendor/vanilo/framework/resources/views and I was wondering if you envisioned a system to override some of these controllers in the framework properly ? SO I could have modified views in my main folder and leave everything untouched in vendor.
Thanks again for your help and this cool project
There were plans on idiomatic controller override, but haven't been implemented (yet) due to the lack of interest (so far) :)
What you can do is to override the route in your project and use your controller for that specific action. As a reference, you can copy the existing methods from the vendor folder.
Does this work for you for the time being?
Hi
Thanks for your answer, yes it will do the trick for now .
To help others, I did
php artisan route:list to see the entry for the OderController in the admin.
I added this entry in my web.php
// Admin overrides
Route::get('admin/order/{order}', 'OrderController@show')->Name('vanilo.order.show');
And I create an OrderController in app
namespace App\Http\Controllers;
use Vanilo\Framework\Http\Controllers\OrderController as VaniloOrderController;
class OrderController extends VaniloOrderController {
public function show(Order $order)
}
}
And I copied only the show method which I needed to change and everything else still falls back to the code in vendor/vanilo...