larastan: Call to an undefined method `withTrashed` - SoftDeletes

$project = $task->project()->withTrashed()->first();

Produce:

Call to an undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::withTrashed().

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 48 (6 by maintainers)

Most upvoted comments

@antonkomarev Thanks for reporting this issue.

I need to think in a solution for this. Since those methods withTrashed, etc are local instance macros instead of global macros.

Give me some time to think.

I am in holidays. I will be back on the 27 August. On Tue 31 Jul 2018 at 10:26, Eric Lagarda notifications@github.com wrote:

Some news? Thanks

— You are receiving this because you were assigned.

Reply to this email directly, view it on GitHub https://github.com/nunomaduro/larastan/issues/40#issuecomment-409156377, or mute the thread https://github.com/notifications/unsubscribe-auth/AFNFVFA7kI9iWndLeqtTyHexj3ActBs_ks5uMCK6gaJpZM4VWcoy .

Just added support to soft deletes v0.3.3. Can you folks run some tests?

@nunomaduro Could you investigate this one?

Guys I found the answer for me, I had the same issue because I changed __construct() method in my model, but forgot to put parent::__construct(); in the beginning of this method

I am getting the same error.

Call to an undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::withTrashed().

    /**
     * An event belongs to a venue.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function venue()
    {
        return $this->belongsTo(Venue::class)->withTrashed();
    }

@nunomaduro Very nice job. Thank you. Larastan knows almost 100% of Laravel.