Jerem-d

Member Since 3 Weeks Ago

Experience Points
220
Total
Experience

4,780 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 your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
220 XP
Apr
20
2 weeks ago
Activity icon

Replied to How To Make Multiple Filter Search In Laravel 8

Thanks. Just tried it and it works as expected

Activity icon

Replied to How To Make Multiple Filter Search In Laravel 8

Thank you!! You saved me.

I'm going to try to use "eloquent-filter" as suggested by @tisuchi to clean my code and yes I was planning to rename "project" variable also.

Have good day guys and thank you again! :)

Activity icon

Replied to How To Make Multiple Filter Search In Laravel 8

Because I want to display all annonces by default and then if the user want to use filter he can get the result that he wants.

That's why I have

 @if($project != "")

in my view.

It used to work before I added categories in my controller and view.

Your solution doesnt work for me. It seems there are no filter working anymore. I would be happy to share more details but I can't see any error message

Activity icon

Replied to How To Make Multiple Filter Search In Laravel 8

I haven't thought about it.

Do you mean something like this ? If yes I still get no errors and filters don't work

    public function show()
    {
        Paginator::useBootstrap();
        $annonces = DB::table('annonces')->paginate(15);
        $project = Annonce::query();


        if (!empty(request('term'))) {
            $project->where('title', 'Like', '%' . request('term') . '%')->orderBy('id', 'DESC');
        }

        if (!empty(request('price')) && request('price') == 'more-expensive') {
            $project->orderBy('price', 'DESC');
        }

        if (!empty(request('price')) && request('price') == 'less-expensive') {
            $project->orderBy('price', 'ASC');
        }

        if (!empty(request('categorie'))) {
            $project->where('categorie', 'Like', '%' . request('categorie') . '%');
        }

        $project->paginate(25);


        return view('welcome', compact('annonces', 'project'));
    }
Activity icon

Replied to How To Make Multiple Filter Search In Laravel 8

Thanks I'll have look :)

Activity icon

Started a new Conversation How To Make Multiple Filter Search In Laravel 8

Hi, still on my way to learn laravel :-)

I made a simple search bar + one filter by less and more expensive prices and it works :

Controller:

    public function show()
    {
        Paginator::useBootstrap();
        $annonces = DB::table('annonces')->paginate(15);
        $project = Annonce::query();


        if (!empty(request('term'))) {
            $project->where('title', 'Like', '%' . request('term') . '%')->orderBy('id', 'DESC')->paginate(15);
            //$project = $project->orderBy('id', 'DESC')->paginate(15);
        }

        if (!empty(request('price')) && request('price') == 'more-expensive') {
            $project = $project->orderBy('price', 'DESC')->paginate(15);
        }

        if (!empty(request('price')) && request('price') == 'less-expensive') {
            $project = $project->orderBy('price', 'ASC')->paginate(15);
        }
}

view:

      <form method="GET" action="/">
        <input type="text" name="term" id="term">
// what I'm trying to add
        <select name="categorie">
          <option value="Animaux">Animaux</option>
          <option value="Multimédia">Multimédia</option>
          <option value="Maison">Maison</option>
          <option value="Loisirs">Loisirs</option>
        </select>

        <select name="price">
        <option value="more-expensive">plus cher</option>
        <option value="less-expensive">Moins cher</option>
        </select>
        <button type="submit">rechercher</button>
      </form>
      @foreach ($project as $item)
		//display $item->title etc..
      @endforeach
      </div>
    @if($project != "") // this one appear only if user use search bar.
    <div class="card-group justify-content-center">
    @foreach ($annonces as $annonce)
		//display $annonce->title etc..
    @endforeach
  </div>
</div>
<div class="row">
  <div class="col-12">
{{ $annonces->links() }}
  </div>
</div>
@endif
</div>
</x-app-layout>

But now I want to add categories and for some reason it doesnt work but I have no errors messages :

  if (!empty(request('categorie'))) {
            $project = $project->where('categorie', 'Like', '%' . request('categorie') . '%');
        }

What i'm looking for is :

  • User select "Animaux" => display all data with the "Animaux" category.
  • User select "Animaux + less expensive" => display all data from "Animaux category order by price asc"
  • User select "Animaux" + search "test" => if no result display nothing, si one then display it.

This is how the url looks like when I try to test my filter :

http://127.0.0.1:8000/?term=&categorie=Animaux&price=more-expensive

I know I can improve my code but for now I want keep things simple and then once I understand why it doesn't work I will refactor it.

If anyone can help me why my filter doesnt works I would appreciate it because I have no error messages from laravel. Thanks :)

Apr
16
3 weeks ago
Activity icon

Replied to Undefined Variable Anonymous Components Laravel 8

Ahaah I hope I will be able to learn most of things by myself and I promise I won't spam the forum :-)

Thank you for your help I'm going to create the component straight away and hope everything will be fine.

Activity icon

Replied to Undefined Variable Anonymous Components Laravel 8

I haven't run "php artisan make:component my_component" because I thought I could just create a file inside the component folder and use it.

Basically I want to use components because breeze use components for the app-layout et and register/login form.

What is the best practice :

  • create components for each of my éléments I will have to use (like list annonce, post annonce etc)
  • use section and include (which seems little bit easier to understand to me) inside the < x-app-layout >

I'm sorry if it's a "stupid" question but we have 1 week to create a webside with laravel and I'have never use any php framework before.

Thanks

edit: I haven't seen your code at first. I will try it. thanks.

Activity icon

Started a new Conversation Undefined Variable Anonymous Components Laravel 8

Hi,

I'm a newbie with laravel and I'm trying to learn how to use components but i'm facing an issue with a "Undefined variable" when I use anonymous components inside a other one.

My indexController return me a welcome view and inside this view I want to include a list of post from a other controller.

index controller

class IndexController extends Controller
{
    public function showIndex()
    {
        return View('welcome');
    }
}

welcome view

<x-app-layout title="welcome">
<p>Welcome page</p>

//component I want to include
<x-annonces-list></x-annonces-list>

</x-app-layout>

ListAnnoncesController

class ListAnnonceController extends Controller
{
    public function show()
    {
        $annonces = DB::table('annonces')->get();
        return View('annonces-list', ['annonces', $annonces]);

    }
}

list I want to show in welcome view (annonce-list component)

<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Odit ipsam autem, nam neque incidunt iure voluptas fugit, quo illo, dicta ducimus maiores. Consequatur molestiae dolore autem saepe? Omnis, distinctio maxime.</p>

@foreach ($annonces as $annonce)
    <p>Title: {{$annonce->title}}</p>
@endforeach

The components folder and <-x-app-layout> have been created when I did install "breeze" package.

Anyone can help me please ??