我有一個架構,稱爲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
不起作用。任何想法爲什麼?我可以解決這個我使用自定義驗證和使用自定義存儲庫方法來檢查是否存在,但我想使用本地方法。