你能不能解释一下为什么你找不到图书馆
找不到错误类‘App\Model\网关’
在/var/www/html/demo//var/www/html/demo/core/resources/views/templates/basic/sections/payment.blade.php中(第2行)
<?php
$payments = App\Models\GateWay::where('status', 1)->latest()->get();
$paymentData = getContent('payment.content', true);
?>
位置是正确的,/var/www/html/demo/core/app/Models/Gateway.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Gateway extends Model
{
protected $guarded = ['id'];
protected $casts = ['status' => 'boolean', 'code' => 'string', 'extra' => 'object','input_form'=> 'object'];
public function currencies()
{
return $this->hasMany(GatewayCurrency::class, 'method_code', 'code');
}
public function single_currency()
{
return $this->hasOne(GatewayCurrency::class, 'method_code', 'code')->latest();
}
public function scopeCrypto()
{
return $this->crypto == 1 ? 'crypto' : 'fiat';
}
public function scopeAutomatic()
{
return $this->where('code', '<', 1000);
}
public function scopeManual()
{
return $this->where('code', '>=', 1000);
}
}
发布于 2022-04-09 22:20:49
我看到要传递给它的类的名称是GateWay。
$payments = App\Models\GateWay::where('status', 1)->latest()->get();
但是在Gateway.php文件中,类名为网关
class Gateway extends Model { ... }
它还检查Gateway.php文件的位置。在我看来,在导入或调用类时,我必须删除App\
。
发布于 2022-04-09 22:21:33
在刀片文件中查询并不是很好的做法,但是如果文件位于正确的位置,名称空间和类名是正确的,那么它应该可以正常工作。即使它不起作用,请尝试composer自动加载和清除缓存配置视图和路由。
我试过了,这对我有用。
<?php
$payments = App\Models\User::where('id', 1)->get();
dd($payments);
// $paymentData = getContent('payment.content', true);
?>
发布于 2022-04-10 01:15:08
因为您在模型类中使用网关名称,并且在将其实现到控制器中时,所以您使用的是GateWay。
因此,您必须将模型类名更改为GateWay
https://stackoverflow.com/questions/71813064
复制相似问题