vanilophp / framework

The truly Laravel E-commerce Framework
https://vanilo.io
MIT License
810 stars 102 forks source link

Override vanilo controllers #51

Open samo9789 opened 5 years ago

samo9789 commented 5 years ago

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

fulopattila122 commented 5 years ago

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?

samo9789 commented 5 years ago

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