framework icon indicating copy to clipboard operation
framework copied to clipboard

Override vanilo controllers

Open samo9789 opened this issue 5 years ago • 2 comments

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

samo9789 avatar Jul 09 '19 21:07 samo9789

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?

fulopattila122 avatar Jul 11 '19 19:07 fulopattila122

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...

samo9789 avatar Jul 12 '19 15:07 samo9789