我有一个架构,称为public
。在这个模式中,我有一个名为currencies
的表。Laravel 5.1 Eloquent - 引用来自验证的不同架构说架构不存在
<?php
declare(strict_types=1);
namespace Lapis\Domain\Currency;
use Lapis\Domain\Core\Database\Eloquent\Model;
/**
* Class EloquentCurrency
*
* @package Lapis\Domain\Currency
*/
class EloquentCurrency extends Model implements CurrencyInterface
{
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'public.currencies';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'symbol',
'code',
'decimal_places',
];
}
一切完美,由于设置$table
为public.currencies
。我可以通过存储库或直接在我的控制器中执行所有CRUD操作。
什么似乎被打破是试图使用exists
规则。
在我的验证,我有:
'name' => [
'required',
'exists:public.currencies',
],
这仅仅是一个节选。最终的验证将会更加复杂,但问题在于,当我称之为public.currencies
时,Laravel无法看到表格。
显然语法
schema.table
不起作用。任何想法为什么?我可以解决这个我使用自定义验证和使用自定义存储库方法来检查是否存在,但我想使用本地方法。