Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Override Route

    General Discussion
    4
    4
    761
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • admin
      admin last edited by

      How can i override route in filter, where can i see them?

      1 Reply Last reply Reply Quote 0
      • R
        rahul last edited by

        Hi @admin

        Can you explain little bit more ?

        Thanks

        1 Reply Last reply Reply Quote 0
        • I
          iateadonut last edited by

          For example, I want to override the default page for a certain category.

          So I extend the controller within my own package:

          class ProductsCategoriesProxyController extends \Webkul\Shop\Http\Controllers\ProductsCategoriesProxyController
          {
          

          In that packages routes file, I override the route:

          Route::fallback(\MyCompany\MyPackage\Http\Controllers\ProductsCategoriesProxyController::class . '@index')
                 ->defaults('_config', [
                     'product_view' => 'shop::products.view',
                     'category_view' => 'shop::products.index'
                 ])
                 ->name('shop.productOrCategory.index')
          

          Now, the question is, how do I make sure that this route, in the packages/MyCompany/MyPackage/src/Http/routes.php ALWAYS SUPERCEDES the route already defined in packages/Webkul/Shop/src/Http/routes.php ?

          1 Reply Last reply Reply Quote 0
          • D
            deepak227 last edited by

            Hello @iateadonut

            For overriding purpose you can override the route.php.

            First you have to make the copy of the file in your package which you want to override then make changes in that file then go to your serviceprovider.php file and write this code in boot() method

              $this->publishes([__DIR__ . 'path-where-file-is-located-in-your-package' => 'path-of-file-which- you-want-to-overide' ]);
            

            After that you can run php artisan vendor:publish --force and select your package.

            This will override the existing file and from that you package controller index will work.

            Thank you. Hope this will work for you.

            Deepak Singh Gusian

            1 Reply Last reply Reply Quote 0
            • First post
              Last post