• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

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

How to create a new route for simple blade view file?

General Discussion
2
4
228
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.
  • A
    aga last edited by 7 Mar 2024, 03:41

    Hello, I am trying to create a new route to direct user to this new blade file, its file path is:

    packages/webkul/store/src/resource/views/shop_the_look/index.blade.php

    the way I write in href:

    <li><a href="{{ route('shop.shop_the_look.index') }}">Shop the Look</a></li>
    

    Where and how I defined route:

    1. packages\Webkul\Shop\src\Http\Controllers\ShopTheLookController.php (also done in new created store package)
    Code:
    <?php
    
    namespace Webkul\Shop\Http\Controllers;
    
    class ShopTheLookController extends Controller
    {
    
        /**
         * Address route index page.
         *
         * @return \Illuminate\View\View
         */
        public function index()
        {
    
            return view('shop.shop_the_look.index');
        }
    }
    
    
    1. packages\Webkul\Shop\src\Routes\store-front-routes.php (also done in new created store package)
    <?php
    
    use Illuminate\Support\Facades\Route;
    use Webkul\Shop\Http\Controllers\CMS\PagePresenterController;
    use Webkul\Shop\Http\Controllers\CompareController;
    use Webkul\Shop\Http\Controllers\HomeController;
    use Webkul\Shop\Http\Controllers\ProductController;
    use Webkul\Shop\Http\Controllers\ProductsCategoriesProxyController;
    use Webkul\Shop\Http\Controllers\SearchController;
    use Webkul\Shop\Http\Controllers\SubscriptionController;
    use Webkul\Shop\Http\Controllers\ShopTheLookController;
    
    Route::group(['middleware' => ['locale', 'theme', 'currency']], function () {
        /**
         * CMS pages.
         */
        Route::get('page/{slug}', [PagePresenterController::class, 'presenter'])
            ->name('shop.cms.page')
            ->middleware('cacheResponse');
    
        /**
         * Fallback route.
         */
        Route::fallback(ProductsCategoriesProxyController::class . '@index')
            ->name('shop.product_or_category.index')
            ->middleware('cacheResponse');
    
        /**
         * Store front home.
         */
        Route::get('/', [HomeController::class, 'index'])
            ->name('shop.home.index')
            ->middleware('cacheResponse');
    
        /**
         * Store front search.
         */
        Route::get('search', [SearchController::class, 'index'])
            ->name('shop.search.index')
            ->middleware('cacheResponse');
    
        Route::post('search/upload', [SearchController::class, 'upload'])->name('shop.search.upload');
    
        /**
         * Subscription routes.
         */
        Route::controller(SubscriptionController::class)->group(function () {
            Route::post('subscription', 'store')->name('shop.subscription.store');
    
            Route::get('subscription/{token}', 'destroy')->name('shop.subscription.destroy');
        });
    
        /**
         * Compare products
         */
        Route::get('compare', [CompareController::class, 'index'])
            ->name('shop.compare.index')
            ->middleware('cacheResponse');
    
        /**
         * Shop the look
         */
        Route::get('shop-the-look', [ShopTheLookController::class, 'index'])
            ->name('shop.shop_the_look.index');
            // ->middleware('cacheResponse');
    
        /**
         * Downloadable products
         */
        Route::controller(ProductController::class)->group(function () {
            Route::get('downloadable/download-sample/{type}/{id}', 'downloadSample')->name('shop.downloadable.download_sample');
    
            Route::get('product/{id}/{attribute_id}', 'download')->defaults('_config', [
                'view' => 'shop.products.index',
            ])->name('shop.product.file.download');
        });
    });
    
    1. routes\breadcrumbs.php
    <?php
    
    use Diglactic\Breadcrumbs\Breadcrumbs;
    use Diglactic\Breadcrumbs\Generator as BreadcrumbTrail;
    
    // Home
    Breadcrumbs::for('home', function (BreadcrumbTrail $trail) {
        $trail->push(trans('shop::app.customers.account.home'), route('shop.home.index'));
    });
    
    // Home > My Account
    Breadcrumbs::for('account', function (BreadcrumbTrail $trail) {
        $trail->parent('home');
        $trail->push(trans('shop::app.layouts.my-account'), route('shop.customers.account.profile.index'));
    });
    
    // Home > My Account > Profile
    Breadcrumbs::for('profile', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.profile'), route('shop.customers.account.profile.index'));
    });
    
    // Home > My Account > Profile > Edit
    Breadcrumbs::for('profile.edit', function (BreadcrumbTrail $trail) {
        $trail->parent('profile');
        $trail->push(trans('shop::app.customers.account.profile.edit'), route('shop.customers.account.profile.index'));
    });
    
    // Home > My Account > Address
    Breadcrumbs::for('addresses', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.address'), route('shop.customers.account.addresses.index'));
    });
    
    // Home > My Account > Address > Create
    Breadcrumbs::for('addresses.create', function (BreadcrumbTrail $trail) {
        $trail->parent('addresses');
        $trail->push(trans('shop::app.customers.account.addresses.add-address'), route('shop.customers.account.addresses.create'));
    });
    
    // Home > My Account > Address > Edit
    Breadcrumbs::for('addresses.edit', function (BreadcrumbTrail $trail, $entity) {
        $trail->parent('addresses');
        $trail->push(trans('shop::app.customers.account.addresses.edit'), route('shop.customers.account.addresses.edit', $entity->id));
    });
    
    // Home > My Account > Orders
    Breadcrumbs::for('orders', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.orders'), route('shop.customers.account.orders.index'));
    });
    
    Breadcrumbs::for('orders.view', function (BreadcrumbTrail $trail, $entity) {
        $trail->parent('orders');
        $trail->push(trans('shop::app.customers.account.orders.view.title'), route('shop.customers.account.orders.view', $entity->id));
    });
    
    // Home > My Account > Downloadable Products
    Breadcrumbs::for('downloadable-products', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.downloadable-products'), route('shop.customers.account.downloadable_products.index'));
    });
    
    // Home > My Account > Reviews
    Breadcrumbs::for('reviews', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.reviews'), route('shop.customers.account.reviews.index'));
    });
    
    // Home > My Account > Wishlist
    Breadcrumbs::for('wishlist', function (BreadcrumbTrail $trail) {
        $trail->parent('account');
        $trail->push(trans('shop::app.layouts.wishlist'), route('shop.customers.account.wishlist.index'));
    });
    
    // Home > Cart
    Breadcrumbs::for('cart', function (BreadcrumbTrail $trail) {
        $trail->parent('home');
        $trail->push(trans('shop::app.checkout.cart.index.cart'), route('shop.checkout.cart.index'));
    });
    
    // Home > Checkout
    Breadcrumbs::for('checkout', function (BreadcrumbTrail $trail) {
        $trail->parent('home');
        $trail->push(trans('shop::app.checkout.onepage.index.checkout'), route('shop.checkout.onepage.index'));
    });
    
    // Home > Comapre
    Breadcrumbs::for('compare', function (BreadcrumbTrail $trail) {
        $trail->parent('home');
        $trail->push(trans('shop::app.compare.product-compare'), route('shop.compare.index'));
    });
    
    // Home > Product
    Breadcrumbs::for('product', function (BreadcrumbTrail $trail, $entity) {
        $trail->parent('home');
        $trail->push($entity->name, route('shop.product_or_category.index', $entity->url_key));
    });
    
    // Home > Shop The Look
    Breadcrumbs::for('shop_the_look', function (BreadcrumbTrail $trail) {
        $trail->parent('home');
        $trail->push(trans('shop::app.shop-the-look.index'), route('shop.shop_the_look.index'));
    });
    

    However error still occur:

    Route [shop.shop_the_look.index] not defined.

    Later I try to clear the route cache and refresh it with laravel command:

    php artisan route:cache , php artisan route:clear
    

    Then, this error popped out:
    Target [Webkul\Store\Contracts\ThemeCustomization] is not instantiable while building [Webkul\Store\Http\Controllers\HomeController].

    Am I following the correct way? Should I cache the route after defining new route?

    1 Reply Last reply Reply Quote 0
    • Rishabh-Webkul
      Rishabh-Webkul last edited by 7 Mar 2024, 04:09

      Hello @aga

      Greetings of the day..!!

      This error is coming due to the package that you have created for creating a custom theme ie Webkul/Store.
      kindly remove your current package and download the same package we have uploaded from the given link of the GitHub Repository.

      link - https://github.com/bagisto/custom-theme

      Try to apply this first then let us know if you are still facing some issues. Hopefully this will help you to resolve your query.

      Thanks & Regards..!!

      A 1 Reply Last reply 7 Mar 2024, 08:55 Reply Quote 0
      • A
        aga @Rishabh-Webkul last edited by 7 Mar 2024, 08:55

        @Rishabh-Webkul
        it works. After apply the new theme files and run:

        php artisan route:cache
        

        this problem fixed
        target [Webkul\Store\Contracts\ThemeCustomization] is not instantiable while building [Webkul\Store\Http\Controllers\HomeController]

        Thanks

        1 Reply Last reply Reply Quote 0
        • 12 days later
        • Rishabh-Webkul
          Rishabh-Webkul last edited by 19 Mar 2024, 07:36

          Hello @aga ,

          Thanks for the update.

          Also, if you like our support, you may give us the review here:- https://www.trustpilot.com/review/bagisto.com

          That would be grateful for us.

          Thanks & Regards,

          Bagisto Team

          1 Reply Last reply Reply Quote 0
          1 out of 4
          • First post
            1/4
            Last post