我有一個的ServiceProvider:Laravel動態創建功能
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use \Validator;
use App\Services\CustomValidator;
class AppServiceProvider extends ServiceProvider
{
public function boot() {
Validator::extend('firstname_fail', 'App\Services\[email protected]');
Validator::extend('lastname_fail', 'App\Services\[email protected]');
Validator::extend('hotel_fail', 'App\Services\[email protected]');
Validator::extend('city_fail', 'App\Services\[email protected]date');
}
}
我有一個模型旅遊,其中有這樣的屬性:名字,姓氏,酒店,城市。並且可以添加一些其他(很多)屬性。
(我知道如何從旅遊模型中的所有字段名稱:$陣列=架構:: getColumnListing(「旅遊者」);)
所以我的問題是如何使動態創建的:
驗證::延伸( 'fieldname_fail', 「應用程序\服務\的CustomValidator @字段名 FailValidator')
裏面的boot()方法?
我試圖用魔法_call的方法,但沒有成功......
感謝任何幫助!:)
我可以聞到這個在網絡上!如此多的魔力就是不好的,當你在30天后回來時,你將不知道這部分應用程序是如何工作的。 – Kyslik