Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

date filter

Hello,

I am trying to create a date filter for the report:

MethodNotAllowedHttpException No message

ReportController.php

    public function searchViewReport(Request $request) {

        $data1 = date("Y-m-d", strtotime($request->start_date));
        $data2 = date("Y-m-d", strtotime($request->expire_date));

        $Report = ReportModel::leftJoin('tb_m_biller_solusi', function($join){
                $join->on('tb_r_solusiorder.productid', '=', 'tb_m_biller_solusi.Productid');
                $join->on('tb_r_solusiorder.billerid', '=', 'tb_m_biller_solusi.Billerid');            
        })
        ->leftJoin('tb_m_biller', 'tb_r_solusiorder.billerid', '=', 'tb_m_biller.biller_id')
        ->where(date("Y-m-d",'paydate'), '>', $data1))
        ->where(date("Y-m-d",'paydate'), '<', $data2));
    

        return view('pages.report.list')
                ->with('list', $Report)
                ->with('date1', $data1)
                ->with('date2', $data2);
    }

I think there is an error on this line :

->where(date("Y-m-d",'paydate'), '>', $data1))

Since paydate is date and time I cannot compare it with $data1 which is date only. What should I do?

0 likes
3 replies
PovilasKorop's avatar

You're missing a semicolon ; after where('paydate', '<', $data2)

davy_yg's avatar
Level 27

I figure that one out. I updated my question. Please re-check thanks.

Cronix's avatar

MethodNotAllowedHttpException

@davy_yg This always means you sent a request to a route that is defined to respond to a different http verb than the route was defined with.

For instance, let's say you have this defined route:

Route::get('posts', 'PostController@index')->name('posts.index');

The route is set up to only respond to a get request.

But then, you try to access that route with a post request (or anything other than a get request).

For example,

<form method="post" action="{{ route('posts.index') }}">

That will always cause that error.

The error has nothing at all to do with the code you're showing. It has to do with the defined route, and then how you're improperly trying to access that defined route.

1 like

Please or to participate in this conversation.