Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

That's because the variable is outside its scope.

From PHP: http://php.net/manual/en/functions.anonymous.php

Closures may also inherit variables from the parent scope. Any such variables must be passed to the use language construct.

To fix it, try this (notice that I added use ($user_id) :

public function scopeRemoveTrash($query, $user_id)
{
	Log::info($user_id); //LINE 52
	return $query->whereNotIn('acts.id', function($removed) use ($user_id) {
  		$removed->select('act_id')->from('trial_acts')->where('user_id', '=', $user_id)->get();
	});
}
0

Thanks thomastkim

Thant was very fast :) Woked perfect.

Much appreciated, Bookmarked the link also.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.