-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Is there any way to extend the core functionalities without modifying the core files? #1753
-
Hi there,
Is there any way to extend the core functionalities without modifying the core files?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 9 replies
-
Hello, @maulik1211,
If I understand correctly, you want to extend or modify the Core facade. If yes, you can do that by creating your own custom package and then extending the base core facade.
For example:
namespace {YourPackageName}; use Webkul\Core\Core as BaseCore; class Core extends BaseCore { // Write your own logic with the features of core functionalities. }
Then, in your CustomPackageServiceProvider
, bind the created facade like this:
use {YourPackageName}\Core; public function register() { $this->app->singleton('core', fn() => app(Core::class)); }
If you need any further help or clarification, feel free to ask!
Beta Was this translation helpful? Give feedback.
All reactions
-
I'm trying to determine how to extend/overwrite views from within a custom package as well. I would like to add to mega-search, the edit leads, and a few other places.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi! 👋
Yes, you can extend or override views from a custom package in Krayin CRM. Here’s a general approach you can follow:
-
Publish the Vendor Views (if needed)
If you're trying to override views from core packages, make sure they are published to the resources/views/vendor directory:
php artisan vendor:publish --tag=views
-
Overriding Views in Your Package|
In your custom package, you can create a resources/views directory and mimic the path of the view you want to override. For example,
to override mega-search, you might do:packages/YourVendor/YourPackage/resources/views/ui/mega-search.blade.php
Then, in your package service provider, make sure to register your views with higher priority:
$this->loadViewsFrom(__DIR__.'/../resources/views', 'yourpackage');
And override the view using Laravel's view override mechanics or by extending the view logic using @includeIf, @section, or custom
Blade components.
Let me know which specific views you're trying to modify (file path or feature) — I can give more detailed help on that!
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks, @VikassWebkul214254.
You outlined the process I have been trying, but unsuccessfully. Perhaps one of these is the challenge:
- I don't have any views to publish:
No publishable resources for tag [views].
- I'm storing my views here:
pacakages/YourVendor/YourPackace/src/Resources/views
and as such loading that directory in my ServiceProvider.php.$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'order');
Any idea why there aren't views for publishing? Does the directory structure create an issue?
Beta Was this translation helpful? Give feedback.
All reactions
-
Have you added the publishes method in your package’s service provider?
If not, you can register it like this:
$this->publishes([ __DIR__.'/../Resources/views/admin/catalog/products/edit/links.blade.php' => resource_path('/views/vendor/admin/catalog/products/edit/links.blade.php'), ]);
In the example above, we’re targeting a specific view file for override. After adding this, run the vendor publish command to publish the files:
php artisan vendor:publish --provider="Webkul\YourPackace\Providers\YourPackaceServiceProvider" --force
Beta Was this translation helpful? Give feedback.
All reactions
-
@VikassWebkul214254, that works for me. Thank you!
However, I can only get the view to load (and override) when the file is located at resources/views/
, which is outside of my packages\Wow\
directory structure. Therefore, the views have to be published with every change.
I don't have to publish self-contained files within my package. Is publishing the only (and proper) way to override views?
Beta Was this translation helpful? Give feedback.