The problem is that when selecting from select it has ware:model, the slider crashes, and when you click on search, it shows 404

142 Views Asked by At

When I use livewire The problem is that when selecting from select it has ware:model, the slider crashes, and when you click on search, it shows 404

As shown in the picturesenter image description here

I tried many times but I don't know why

//my view

div class="ne-sidebar sidebar-break-lg col-xl-4 col-lg-12 px-0">

            <div class="sidebar-box item-box-light-md">
              <div class="topic-border color-cinnabar mb-30">
                <div class="topic-box-lg color-cinnabar">{{__("translate.Search")}} </div>
              </div>
              <div class="bodyimg">
                <form action="{{route('advancedPost.search')}}" method="post" name="dmarticlesFilter" id="dmarticlesFilter">
                    @csrf
            <div id="dmarticlesfilter_filters">
                <div class="dmarticlesfilter_filters_row">
                <select id="filterCategory634bd4c1cb9b5_0" wire:model="fcategory_id">
                            <option>{{__("translate.choose")}}</option>
                            @foreach($firstcategories as $fcat)
                              <option value="{{$fcat->id}}">{{$fcat->name}}</option>
                            @endforeach
                    </select>



                    <select id="filterCategory634bd4c1cb9b5_1" wire:model="scategory_id">
                            <option>{{__("translate.choose")}}</option>
                            @foreach($secondcategories as $scat)
                              <option value="{{$scat->id}}">{{$scat->name}}</option>
                            @endforeach
                    </select>


                        </div>

                        <div class="dmarticlesfilter_filters_values_l">
                            <input placeholder="Title" type="text" name="filterTitle" value="">

                    <span><input type="submit" class="button" id="button" value="{{__('translate.Search')}}"> </span>&nbsp;&nbsp;
                    <a > {{__("translate.UserGuid")}}</a>
                  </div>
                    </div>

                </form>
                </a>
              </div>
            </div>


//my controller

<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\category;
use App\Models\post;
use App\Models\firstcategory;
use App\Models\secondcategory;
use App\Models\thirdcategory;
use App\Models\fourthcategory;
use DB;
class HomeComponent extends Component
{
    public $fcategory_id;
    public $scategory_id;
    public $tcategory_id;


    public function render()
    {


        /***************************** */
        $firstcategories = firstcategory::all();
        $secondcategories = secondcategory::where('fcategory_id',$this->fcategory_id)->get();
        $thirdcategories = thirdcategory::where('scategory_id',$this->scategory_id)->get();
        $fourthcategories = fourthcategory::where('tcategory_id',$this->tcategory_id)->get();


        return view('livewire.home-component',['fourthcategories'=>$fourthcategories,'thirdcategories'=>$thirdcategories,'secondcategories'=>$secondcategories,'firstcategories'=>$firstcategories])->layout('layouts.base');
    }
}

I think the problem is with livewire with wire:model

//the method in Livewire component that handles the form it get value from the select then search by the the value

class AdvancedSearchComponent extends Component
{
    public function render(Request $req)
    {
        $posts = post::where('fourCatID',$req->foucategory_id)->get();
        return view('livewire.advanced-search-component',['posts'=>$posts])->layout('layouts.base');
    }
}
0

There are 0 best solutions below