本文整理汇总了PHP中Illuminate\Database\Eloquent\Relations\Relation::morphMap方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::morphMap方法的具体用法?PHP Relation::morphMap怎么用?PHP Relation::morphMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Relations\Relation
的用法示例。
在下文中一共展示了Relation::morphMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap(['quran_recordings' => \Modules\Quran\Entities\QuranRecording::class]);
}
示例2: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot(Router $router)
{
$router->model('uuser', '\\Modules\\Users\\Entities\\User');
$router->model('urole', '\\Bican\\Roles\\Models\\Role');
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap(['users' => \Modules\Users\Entities\User::class]);
}
示例3: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap(['paper_doc' => \Modules\Papers\Entities\PaperDoc::class, 'paper_semster_doc' => \Modules\Papers\Entities\PaperSemesterDoc::class]);
}
示例4: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap(['order_quran_excuses' => \Modules\Orders\Entities\OrderQuranExcuse::class]);
}
示例5: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap([]);
}
示例6: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
Relation::morphMap(['teachers' => \Modules\Teachers\Entities\Teacher::class]);
}
示例7: register
/**
* Register the User module service provider.
*
* @return void
*/
public function register()
{
// This service provider is a convenient place to register your modules
// services in the IoC container. If you wish, you may make additional
// methods or service providers to keep the code more focused and granular.
App::register('App\\Modules\\User\\Providers\\RouteServiceProvider');
App::register('App\\Modules\\User\\Providers\\RepositoryServiceProvider');
Relation::morphMap([config('user_module.user_types.administrator') => App\Modules\User\Models\Administrator::class]);
$this->registerNamespaces();
}
示例8: boot
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
StudentGrade::creating(function ($grade) {
$grade->semester_id = semester()->id;
});
Relation::morphMap(['students' => \Modules\Students\Entities\Student::class]);
}
示例9: register
/**
* Register any package services.
*
* @return void
*/
public function register()
{
$configPath = realpath(__DIR__ . '/../config/loggableModels.php');
$this->publishes([$configPath => $this->getConfigPath()], 'config');
$this->publishes([realpath(__DIR__ . '/../database/migrations/') => database_path('migrations')], 'migrations');
// Define Custom Polymorphic Types
Relation::morphMap([]);
$this->mergeConfigFrom($configPath, 'loggableModels');
$this->app->bind('loggable-models', function () {
return new ModelLogHandler();
});
}
示例10: addConversionsFromRelatedModel
/**
* Add the conversion that are defined on the related model of
* the given media.
*
* @param \Spatie\MediaLibrary\Media $media
*/
protected function addConversionsFromRelatedModel(Media $media)
{
$modelName = Arr::get(Relation::morphMap(), $media->model_type, $media->model_type);
/*
* To prevent an sql query create a new model instead
* of the using the associated one
*/
$model = new $modelName();
if ($model instanceof HasMediaConversions) {
$model->registerMediaConversions();
}
$this->items = $model->mediaConversions;
}
示例11: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(GateContract $gate, Router $router)
{
// set view paths
$this->loadViewsFrom(resource_path('ohio/content/views'), 'ohio-content');
// set backup view paths
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'ohio-content');
// policies
$this->registerPolicies($gate);
// morphMap
Relation::morphMap(['content/page' => Content\Page\Page::class]);
// commands
$this->commands(Content\Base\Commands\PublishCommand::class);
Validator::extend('unique_route', \Ohio\Content\Base\Validators\RouteValidator::class . '@routeIsUnique');
}
示例12: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Validator function to check password hashes
Validator::extend('hashed', function ($attribute, $value, $parameters) {
// If we're already logged in
if (Auth::check()) {
$user = Auth::user();
} else {
// Otherwise, try to get the username from form input
$user = User::where('name', Input::get('name'))->get();
if (!$user->count()) {
return false;
}
$user = $user[0];
}
if (Hash::check($value, $user->password)) {
return true;
}
return false;
});
// Define polymorphic relationship models
Relation::morphMap(['question' => \App\Models\Question::class, 'document' => \App\Models\Document::class]);
}
示例13: register
/**
* Register any application services.
*
* @return void
*/
public function register()
{
\Illuminate\Database\Eloquent\Relations\Relation::morphMap([\App\Applicant::class, \App\Quota::class]);
}
示例14: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Relation::morphMap(['user' => \App\Models\User::class, 'admin' => \App\Models\Admin::class]);
}
示例15: getMorphClass
/**
* Get the class name for polymorphic relations.
*
* @return string
*/
public function getMorphClass()
{
$morphMap = Relation::morphMap();
$class = static::class;
if (!empty($morphMap) && in_array($class, $morphMap)) {
return array_search($class, $morphMap, true);
}
return $class;
}