-1

I'm making a web app with Laravel and I want to filter elements by creation date. The format I need is yyyy-mm-dd. This is what I've tried:

Form to pick a date:

<form method="post" action="{{ route('dateFilter',[$subject,$date]) }}">
    <input type="date" class="datepicker" name="date" >
    <input type="hidden" value="{{ $subject }}" name="subject">

    <input class="btn btn-primary submit-date" type="submit" name="submitDate">
</form>

This is the route I created:

Route::get('/view/{subject}/{date}', 'EntryController@filter')->name('dateFilter');

And this is the function on the controller, it just displays the output for now just to get this step done:

public function filter($request){
    print_r($request);
}

Right now if I try to pick a date and submit the form I get the following url: http://localhost/view/LMSG/Tuesday,%2008/10%20?date=2019-10-07&subject=LMSG

What I need to have is something like /view/LMSG/2019-10-07

1
  • 1
    tell your datepicker (configure) to return the date in the format you want it Commented Oct 8, 2019 at 9:08

1 Answer 1

0

Maybe something like

<form method="post" action="{{ route('dateFilter',[$subject, $date->format('Y-m-d')]) }}">
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.