Adams_'s avatar

The GET method is not supported for this route. Supported methods: POST.

So I have this livewire component with filters, search and pagination features, and everything is working fine, but after searching or filtering when I click next page on the pagination I get this error

The GET method is not supported for this route. Supported methods: POST.

so I read on the documentation you have to reset the page with $this->resetPage() on updatedProperty which I did but then I got this error Method App\Http\Livewire\Members\MembersIndex::resetPage does not exist. Please any help is appreciated Here is my component

 class MembersIndex extends Component
{   
public $search = "";
public $pagination = 8;
public $filteredCities      = null;
public $selectedHouseFilter = null;
public $FilterByState       = null;
public $FilterByCity        = null;
public $FilterByProfession  = null;
public $cities;
public $selectedYear;
public $term;
public $filterByCategory;
public $firstName;
public $lastName;
public $middleName;
public $birthDate;
public $state;
public $city;
public $profession;
public $gradYear;
public $house;
public $workplace;
public $potraitImage;
public $profileImage;
public $memberId;
public $simpleModal;
public $address;
public $email;
public $phone;
public $facebook, $twitter, $instagram , $whatsapp, $telegram, $linkedin, $website;


 public function updatingSearch()
{
     $this->resetPage();

}

public function ClearFilters()
{
    $this->search = '';
    $this->filteredCities = '';
    $this->selectedHouseFilter = '';
    $this->FilterByState = '';
    $this->FilterByCity = '';
    $this->FilterByProfession = '';

    // $this->resetPage();
}

public function ProfileModal($id)
{
    $this->memberId = $id;
    $this->simpleModal = true;
    $this->profileDetails();

    $member = User::find($this->memberId);

    $profileKey = 'profile_'.$member->id;

    if (!Session::has($profileKey)) {
        $member->incrementViewCount();//count the view
        Session::put($profileKey, 1);
    }

}

       public function profileDetails()
   {

    $member = User::find($this->memberId);

    $userSocialLinks = SocialMediaLink::where('user_id', $this->memberId )->first();

  $this->firstName = $member->first_name;
  $this->lastName = $member->last_name;
  $this->middleName = $member->middle_name;
  $this->profileImage = $member->profile_photo_path;
  $this->potraitImage = $member->potrait_image;
  $this->profession = $member->profession;
  $this->workplace = $member->workplace;
  $this->address = $member->address;
  $this->email = $member->email;
  $this->phone  = $member->phone; 
  $this->gradYear = $member->graduationYear->year;
  $this->facebook = $userSocialLinks->facebook ?? " No social media handle for this user";
  $this->twitter = $userSocialLinks->twitter ?? " No social media handle for this user";
  $this->instagram = $userSocialLinks->instagram  ?? "No social media handle for this user ";
  $this->whatsapp = $member->socialMedia->whatsapp ?? "No social media handle for this user ";
  $this->telegram = $member->socialMedia->telegram ?? "No social media handle for this user ";
  $this->linkedin = $member->socialMedia->linkedin ?? "No social media handle for this user ";
  $this->website = $member->socialMedia->website ?? "No social media handle for this user ";
   }


     public function updatedSelectedState($state_id)
    {

    $this->cities = Lga::where('state_id', $state_id)->get();
    
   }

    public function updatedFilterByState($state_id)
    {

    $this->cities = Lga::where('state_id', $state_id)->get();

    
 }

 public function getUsersProperty()
{
    return $this->usersQuery->paginate($this->pagination);

    

}

 public function getUsersQueryProperty()
{
    
    return User::with(['Categories','house','gender','events','state','city'])->when($this->selectedHouseFilter, function($query) {
        
        $query->where('house_id', $this->selectedHouseFilter);
        })->when($this->FilterByState, function($query) {$query->where('state_id',$this->FilterByState);
        })->when($this->FilterByCity, function($query) {$query->where('city_id', $this->FilterByCity);
        })->when($this->selectedYear, function($query) {$query->where('graduation_year_id', $this->selectedYear);
        })->when($this->FilterByProfession, function($query) {
        $query->WhereHas('Categories', function ($query) {
        $query->where('category_id', $this->FilterByProfession);
        });
        })->search(trim($this->search));

        // $this->resetPage();
}

      public function render()
    {
   

    return view('livewire.members.members-index', [
        'members' => $this->users,
        'states' => State::all(),
        'houses' => House::all(),
        'genders' => Gender::all(),
        'maritalStatuses' => MaritalStatus::all(),
        'professionCategories' => Category::all(),
         'years' => GraduationYears::all()
      
    ]);
    

    }
  }
0 likes
3 replies
Adams_'s avatar

@Sinnbeck That was it! I didnt' add the WithPagination trait, all this time I thought I added it, Thank you Sir.

Tray2's avatar

Read the error once again,

The GET method is not supported for this route. Supported methods: POST.

What you are trying to do is go to a route that doesn't exist in your routes file.

There are two things that can be wrong.

  1. The route really doesn't exist in the routes file.
  2. The link generated for the second page does not point to the proper URI, it points to a URI that only has a post route.
1 like

Please or to participate in this conversation.