當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Relation::morphMap方法代碼示例

本文整理匯總了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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:12,代碼來源:QuranServiceProvider.php

示例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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:14,代碼來源:UsersServiceProvider.php

示例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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:12,代碼來源:PapersServiceProvider.php

示例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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:12,代碼來源:OrdersServiceProvider.php

示例5: boot

 /**
  * Boot the application events.
  *
  * @return void
  */
 public function boot()
 {
     $this->registerTranslations();
     $this->registerConfig();
     $this->registerViews();
     Relation::morphMap([]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:12,代碼來源:ExamsServiceProvider.php

示例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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:12,代碼來源:TeachersServiceProvider.php

示例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();
 }
開發者ID:damnyan,項目名稱:laravel,代碼行數:15,代碼來源:UserServiceProvider.php

示例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]);
 }
開發者ID:hisambahaa,項目名稱:DARES,代碼行數:15,代碼來源:StudentsServiceProvider.php

示例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();
     });
 }
開發者ID:topix-hackademy,項目名稱:loggable-models,代碼行數:17,代碼來源:ServiceProvider.php

示例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;
 }
開發者ID:henrikmartinsson,項目名稱:laravel-medialibrary,代碼行數:19,代碼來源:ConversionCollection.php

示例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');
 }
開發者ID:ohiocms,項目名稱:content,代碼行數:19,代碼來源:OhioContentServiceProvider.php

示例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]);
 }
開發者ID:playatech,項目名稱:weightlifter,代碼行數:28,代碼來源:AppServiceProvider.php

示例13: register

 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     \Illuminate\Database\Eloquent\Relations\Relation::morphMap([\App\Applicant::class, \App\Quota::class]);
 }
開發者ID:threening,項目名稱:laraseda,代碼行數:9,代碼來源:AppServiceProvider.php

示例14: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Relation::morphMap(['user' => \App\Models\User::class, 'admin' => \App\Models\Admin::class]);
 }
開發者ID:nutsdo,項目名稱:nong-store,代碼行數:9,代碼來源:AppServiceProvider.php

示例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;
 }
開發者ID:scrubmx,項目名稱:framework,代碼行數:14,代碼來源:Model.php


注:本文中的Illuminate\Database\Eloquent\Relations\Relation::morphMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。