kmj1993

kmj1993

Member Since 1 Year Ago

Experience Points 170
Experience Level 1

4,830 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

12 Nov
1 year ago

kmj1993 started a new conversation Want To Add Pagination To Search Product Page In Laravel

I want to add pagination to my searching product item view using my show controller

This is my controller

public function show($id) { $categories = Item::all();

$products = Item::find($id)->products->paginate(3);

return view('category.index', compact('categories', 'products'));

} This is my view

@extends('layout.front')

@section('page')

<!-- Page Content -->
<div class="container">

    <div class="row">

        <div class="col-lg-3" style="margin-top:20px;">

            <nav class="main-nav">
                <ul class="main-nav-ul">
                    <li style="background-color: #343A40; color: #ffffff; font-weight: 600;" id="sidebar-header"><a>Product List</a></li>
                    <li><a href="{{ url('/computer') }}" style="font-weight: 600;">Computer<span></span></a>
                        <ul>
                            @if(!empty($categories))
                                @forelse($categories as $category)
                                    <li><a href="{{ route('category.show', $category->id)}}">{{ $category->name }}</a></li>

                                @empty
                                    <li>No data found</li>
                                @endforelse
                            @endif
                        </ul>
                    </li>
                    <li><a href="#" style="font-weight: 600;">CCTV</a></li>
                    <li><a href="#" style="font-weight: 600;">Gaming</a></li>
                </ul>
            </nav>

        </div>
        <!-- /.col-lg-3 -->

        <div class="col-lg-9">


            <div class="row" style="margin-top:20px;">


                @if(!empty($products))
                    @foreach($products as $key=>$product)
                        <div class="col-md-4 col-sm-6 portfolio-item" id="items">
                            <div class="card h-100">

                                <a href="#"><img class="card-img-top" src="/storage/{{ $product->image }}" alt="Product Image"></a>
                                <div class="card-body">
                                    <h4 class="card-title">
                                        <a href="#">{{ $product->category_name }}<br />{{ $product->item_name}}</a>
                                    </h4>
                                    <p class="card-text" style="color: #A9A9A9;text-decoration: line-through;">LKR {{ $product->old_price}}</p>
                                    <h4 style="text-align: center; color: #fff;"><a class="waves-effect waves-light btn btn-dark btn-block">LKR {{ $product->new_price}}</a></h4>

                                    {{[email protected]}}
                                </div>
                            </div>
                        </div>
                    @endforeach
                @endif

            </div>
            <!-- /.row -->

        </div>
        <!-- /.col-lg-9 -->

    </div>
    <!-- /.row -->

</div>
<!-- /.container -->
{!! $products->links() !!} @endsection

i used laravel default pagination and customize my bootstrap pagination to laravel.

But in my show function in controller pagination not working. how to fix searching products pagination.

i used links method. but it's not working for this view.

{!! $comproducts->links() !!}

11 Nov
1 year ago

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

when i using forelse this works fine. but bootstrap div views not showing perfectly.

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

This is my modal function

public function products() {

    return $this->hasMany('App\Comproduct','category_id');
}

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

I try forelse and it works correctly. but i want to show my products as cards. forelse show all in same card menu

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

I want to pass my category list and product items in same view.but i cannot pass these two variables from controller to my view. It shows this error.

Undefined variable: products (View: /var/www/html/hzone_new/resources/views/category/index.blade.php)

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

This is my view

@extends('layout.front')

@section('page')

 <div class="row" id="portfolio">


    <!-- Page Content -->
    <div class="container">

        <div class="row">

            <div class="col-lg-3" style="margin-top:20px;">

                <nav class="main-nav">
                    <ul class="main-nav-ul">
                        <li style="background-color: #343A40; color: #ffffff; font-weight: 600;" id="sidebar-header"><a>Product List</a></li>
                        <li><a href="#" style="font-weight: 600;">Computer<span></span></a>
                            <ul>
                                @if(!empty($categories))
                                    @forelse($categories as $category)
                                    <li><a href="{{ route('category.show', $category->id)}}">{{ $category->name }}</a></li>

                                    @empty
                                        <li>No data found</li>
                                    @endforelse
                                @endif
                            </ul>
                        </li>
                        <li><a href="#" style="font-weight: 600;">CCTV</a></li>
                        <li><a href="#" style="font-weight: 600;">Gaming</a></li>
                    </ul>
                </nav>

            </div>
            <!-- /.col-lg-3 -->

            <div class="col-lg-9">


                <div class="row" style="margin-top:20px;">


       
                        @foreach($products as $key=>$product)
                            <div class="col-md-4 col-sm-6 portfolio-item" id="items">
                                <div class="card h-100">

                                    <a href="#"><img class="card-img-top" src="/storage/{{ $product->image }}" alt="Product Image"></a>
                                    <div class="card-body">
                                        <h4 class="card-title">
                                            <a href="#"><br />{{ $product->item_name}}</a>
                                        </h4>
                                        <p class="card-text" style="color: #A9A9A9;text-decoration: line-through;">LKR {{ $product->old_price}}</p>
                                        <h4 style="text-align: center; color: #fff;"><a class="waves-effect waves-light btn btn-dark btn-block">LKR {{ $product->new_price}}</a></h4>
                                      
                                    </div>
                                </div>
                            </div>
                        @endforeach
                        

                </div>
                <!-- /.row -->

            </div>
            <!-- /.col-lg-9 -->

        </div>
        <!-- /.row -->

    </div>
    <!-- /.container -->





</div>

@endsection

kmj1993 left a reply on How To Pass Multiple Variables In To A View Using Controller

This is my controller

public function show($id)
{
    $products = Item::find($id)->products;

    $categories = Item::all();

    return view('category.index', compact(['categories', 'products']));
}

kmj1993 started a new conversation How To Pass Multiple Variables In To A View Using Controller

How to pass multiple variables in a controller in a one view using foreach loop