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

david2000's avatar

Call to a member function where Date() on string

Hello,

I have like error message: "Call to a member function whereDate() on string".

I need to convert the date?

In my form revision.index I have tested this now:

@foreach($revisions as $revision)
<tr>
<td>{{ Carbon\Carbon::parse($revision->date_revision_start->format('d/m/Y') }}</td>
<td>{{ Carbon\Carbon::parse($revision->date_revision_end->format('d/m/Y') }}</td>
<td>{{ $revision->garage }}</td>
 <td>{{ $revision->motorbikes->number_motorbike }}</td>
  <td>

The error message is **syntax error, unexpected ';', expecting ',' or ')' (View: **

My model Revision

protected $fillable = ['date_revision_start', 'date_revision_end', 'garage', 'fk_motorbike'];

protected $dates = ['date_revision_start', 'date_revision_end'];

My table Revisions

public function up()
    {
        Schema::create('revisions', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->date('date_revision_start');
            $table->date('date_revision_end');
            $table->string('garage');
            $table->integer('fk_motorbike')->unsigned();
            $table->foreign('fk_motorbike')->references('id')->on('motorbikes');
            $table->timestamps();
        });
    }

I forgot a step?

Thank you for your help

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

You're missing a closing parenthesis, so whereDate is called on $request->get(fk_motorbike):

Revision::where('fk_motorbike', $request->get('fk_motorbike'))->whereDate(...

Please or to participate in this conversation.