Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::withTimestamps()

Updated at 25-Apr-2022, By samarjeet kumar

Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::withTimestamps()

We will use programming in this lesson to attempt to solve the "Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::withTimestamps()".

  • Solution for error Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::withTimestamps()

    --PATH app\Models\Post.php
    return $this->hasMany('App\Models\Post', 'user_id', 'id')->withTimestamps();  
    //Remove ->withTimestamps() from code 
    return $this->hasMany('App\Models\Post', 'user_id', 'id');
    

Back to code snippet queries related laravel