Laravel试图获取非对象的属性在本地工作,而不是在生产上
我在生产环境中遇到问题,但在本地工作。当用户是卖方时,它在本地和生产环境中工作;当用户不是卖方时,它在本地工作,但不在生产环境中工作。转储属性中包含不同内容的变量,原始和保护 我的控制器就是这个Laravel试图获取非对象的属性在本地工作,而不是在生产上,laravel,eloquent,Laravel,Eloquent,我在生产环境中遇到问题,但在本地工作。当用户是卖方时,它在本地和生产环境中工作;当用户不是卖方时,它在本地工作,但不在生产环境中工作。转储属性中包含不同内容的变量,原始和保护 我的控制器就是这个 if(auth::user()->vendedor == 1){ $actividades = Actividad::with('Prospecto')->whereHas('Prospecto', function($q){ $q
if(auth::user()->vendedor == 1){
$actividades = Actividad::with('Prospecto')->whereHas('Prospecto', function($q){
$q->where('userid', auth::user()->id);
})->get();
dd($actividades);
}else{
$actividades = Actividad::all();
dd($actividades);
}
本地转储:
#items: array:137 [▼
0 => Actividad {#578 ▼
#connection: "mysql"
#table: "actividads"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:10 [ …10]
#original: array:10 [ …10]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:1 [ …1]
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [ …1]
}
生产转储:
#items: array:1 [▼
0 => Actividad {#395 ▼
#connection: "mysql"
#table: "actividads"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:10 [▶]
#original: array:10 [▶]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:1 [▶]
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
如您所见,数组在属性上显示不同,原始和保护
我做了一些测试,如果我使用不同的符号,它会工作,但我不明白为什么本地输出和生产输出之间会有差异
prospect['empresa'];
而不是
prospect->empresa;
我在本地使用Xampp并在生产中使用DO。问题可能是
auth::user()
。Windows不关心大小写,但Unix关心大小写<代码>身份验证::用户()不正确。它应该是auth()->user()
或auth::user()
。可能是缓存问题。在生产服务器上尝试php-artisan-config:cache
&php-artisan-cache:clear
。