Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is there any way to extend the core functionalities without modifying the core files? #1753

Unanswered
maulik1211 asked this question in Q&A
Discussion options

Hi there,
Is there any way to extend the core functionalities without modifying the core files?

You must be logged in to vote

Replies: 1 comment 9 replies

Comment options

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!

You must be logged in to vote
9 replies
Comment options

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?

Comment options

Hi! 👋

Yes, you can extend or override views from a custom package in Krayin CRM. Here’s a general approach you can follow:

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

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

Comment options

Thanks, @VikassWebkul214254.

You outlined the process I have been trying, but unsuccessfully. Perhaps one of these is the challenge:

  1. I don't have any views to publish: No publishable resources for tag [views].
  2. 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?

Comment options

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

Comment options

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /