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


PHP Model::getTable方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Model::getTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::getTable方法的具體用法?PHP Model::getTable怎麽用?PHP Model::getTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Model的用法示例。


在下文中一共展示了Model::getTable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * @param \Illuminate\Database\Eloquent\Model $model
  * @param \anlutro\LaravelValidation\ValidatorInterface $validator
  */
 public function __construct(Model $model, ValidatorInterface $validator = null)
 {
     parent::__construct($validator);
     $this->model = $model;
     if ($validator) {
         $validator->replace('table', $this->model->getTable());
     }
 }
開發者ID:viniciusferreira,項目名稱:laravel-repository,代碼行數:12,代碼來源:EloquentRepository.php

示例2: requireById

 /**
  * Get Record by its ID, with an exception if not found
  *
  * @param $id
  * @return mixed
  * @throws \App\Core\Repository\EntityNotFoundException
  */
 public function requireById($id)
 {
     $model = $this->getById($id);
     if (!$model) {
         throw new EntityNotFoundException($id, $this->model->getTable());
     }
     return $model;
 }
開發者ID:shinichi81,項目名稱:lentera,代碼行數:15,代碼來源:EloquentRepository.php

示例3: __construct

 /**
  * @param Model $model
  * @param Repository $cache
  * @param Dispatcher $dispatcher
  */
 public function __construct(Model $model, Repository $cache, Dispatcher $dispatcher)
 {
     // DI Member Assignment
     $this->model = $model;
     $this->cache = $cache;
     $this->dispatcher = $dispatcher;
     // Set the resource name
     $this->resourceName = $this->model->getTable();
     $this->className = get_class($model);
 }
開發者ID:srlabs,項目名稱:groundwork,代碼行數:15,代碼來源:BaseRepository.php

示例4: forCompany

 public function forCompany()
 {
     $modelForeignId = $this->model->getTable() . '.' . str_singular($this->throughTableName) . '_id';
     $constraint = $this->throughTableName . '.id' . ' = ' . $modelForeignId;
     return $this->model->whereExists(function ($query) use($modelForeignId, $constraint) {
         $query->selectRaw(1)->from($this->throughTableName)->where('company_id', '=', $this->companyId)->whereRaw($constraint);
         if (!is_null($this->throughId)) {
             $query->where('id', '=', $this->throughId);
         }
     });
 }
開發者ID:rekale,項目名稱:sikasir,代碼行數:11,代碼來源:EloquentThroughCompany.php

示例5: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder $builder
  * @param  \Illuminate\Database\Eloquent\Model $model
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     //Check if is an override
     //
     $iso = config()->get('local_override');
     if (empty($iso)) {
         $iso = app()->getLocale();
     }
     $builder->whereExists(function ($query) use($model, $iso) {
         $query->select(\DB::raw(1))->from($model->getQualifiedTable())->whereRaw($model->getTable() . '.' . $model->getKeyName() . ' = ' . $model->getQualifiedIdElementColumn())->where($model->getQualifiedIsoColumn(), $iso)->where($model->getQualifiedModelColumn(), $model->getTable());
     });
     $this->extend($builder);
 }
開發者ID:SchizoDuckie,項目名稱:Expendable,代碼行數:20,代碼來源:TranslatableScope.php

示例6:

 /**
  * @param Command $command
  * @param string $modelClass
  * @param string $title
  */
 function __construct(Command $command, $modelClass, $title)
 {
     $this->command = $command;
     $this->schemaManager = DB::getDoctrineSchemaManager();
     $this->schemaManager->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     $this->modelClass = $modelClass;
     $this->instance = new $this->modelClass();
     $this->table = $this->instance->getTable();
     $this->title = $title;
     $this->with = [];
     $this->columns = [];
     $this->filters = [];
     $this->formItems = [];
 }
開發者ID:DimaPikash,項目名稱:eshop,代碼行數:19,代碼來源:ModelCompiler.php

示例7: makeRepository

 protected function makeRepository()
 {
     $this->model = new \anlutro\Core\Auth\Users\UserModel();
     $this->validator = m::mock('anlutro\\Core\\Auth\\Users\\UserValidator');
     $this->validator->shouldReceive('replace')->with('table', $this->model->getTable());
     return new \anlutro\Core\Auth\Users\UserRepository($this->model, $this->validator);
 }
開發者ID:anlutro,項目名稱:l4-core,代碼行數:7,代碼來源:AuthUserRepositoryTest.php

示例8: transformCustomConstraint

 /**
  * @param JoinClause $query
  * @param string $column
  * @param mixed $values
  * @param string $operator
  *
  * @throws \InvalidArgumentException
  */
 private function transformCustomConstraint($query, $column, $values, $operator)
 {
     if (is_string($column) && !Str::contains($column, '.')) {
         $column = $this->related->getTable() . '.' . $column;
     }
     $values = $this->transformConstraintObject($values);
     if (is_array($values)) {
         if (count($values) > 0) {
             switch ($operator) {
                 case '=':
                     $query->whereIn($column, $values);
                     break;
                 case '!=':
                     $query->whereNotIn($column, $values);
                     break;
                 case 'b':
                     $query->where($column, '>=', $this->transformConstraintObject($values[0]))->where($column, '<=', $this->transformConstraintObject($values[1]));
                     break;
                 case '!b':
                     $query->where($column, '<=', $this->transformConstraintObject($values[0]))->orWhere($column, '>=', $this->transformConstraintObject($values[1]));
                     break;
                 default:
                     throw new \InvalidArgumentException('Join constraint has an invalid operator defined.');
                     break;
             }
         }
     } else {
         $query->where($column, $operator, $values);
     }
 }
開發者ID:brazenvoid,項目名稱:better-eloquent,代碼行數:38,代碼來源:JoinBuilder.php

示例9: aggregate

 /**
  * Aggregates data handling to the subclasses.
  *
  * @param  array       $data  the handling internediate data.
  * @param  array|Model $value the handling Model instance.
  * @return array              the resulting intermediate Format instance.
  */
 protected function aggregate(array $data, Model $value)
 {
     $data[self::KEY_OF_TABLE_NAME] = $value->getTable();
     $data[self::KEY_OF_FOREIGN_KEY] = $value->getForeignKey();
     $data[self::KEY_OF_OTHER_KEY] = $value->getOtherKey();
     return $data;
 }
開發者ID:shingoOKAWA,項目名稱:yacache-l5-php,代碼行數:14,代碼來源:PivotFormat.php

示例10: scanTable

 /**
  * Export a column from a table.
  *
  * @param resource $fp
  * @param Model    $entity
  * @param string   $key_column
  * @param string   $data_column
  * @param string   $comment
  */
 private function scanTable($fp, Model $entity, $key_column, $data_column, $comment)
 {
     $table = $entity->getTable();
     $this->info($table . '...');
     foreach ($entity->where($data_column, '<>', '')->get() as $item) {
         fprintf($fp, self::PO_FORMAT, 'DATABASE: ' . $key_column . '="' . $item->getAttribute($key_column) . '"', $comment, $item->getAttribute($data_column));
     }
 }
開發者ID:fisharebest,項目名稱:webtrees-core,代碼行數:17,代碼來源:DumpPotCommand.php

示例11: checkQuerySelects

 protected function checkQuerySelects()
 {
     $selects = $this->query->getQuery()->columns;
     $tableSelect = $this->model->getTable() . '.*';
     if (empty($selects) || !in_array($tableSelect, $selects)) {
         $this->query->addSelect($tableSelect);
     }
 }
開發者ID:anlutro,項目名稱:l4-core,代碼行數:8,代碼來源:RelationshipQueryJoiner.php

示例12: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->response = \Response::api();
     if (!empty($this->modelName)) {
         $this->model = new $this->modelName();
     }
     // if no collection name provided, use the model's table name
     if (empty($this->collectionName)) {
         $this->collectionName = $this->model->getTable();
     }
     // parse includes
     if (\Input::get('include') != '') {
         $this->manager = new \League\Fractal\Manager();
         $this->manager->parseIncludes(explode(',', \Input::get('include')));
     }
     parent::__construct();
 }
開發者ID:ddimaria,項目名稱:Laravel-REST-CMS,代碼行數:20,代碼來源:ApiController.php

示例13: apply

 public function apply(Builder $builder, Model $model)
 {
     $table = $model->getTable();
     $columns = $model->getDefaultOrderableColumns() ?: [];
     foreach ($columns as $column => $order) {
         $builder->orderBy("{$table}.{$column}", $order);
     }
 }
開發者ID:laratools,項目名稱:laratools,代碼行數:8,代碼來源:DefaultOrderableScope.php

示例14: formatEloquentModel

 /**
  * Format an Eloquent model.
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  *
  * @return string
  */
 public function formatEloquentModel($model)
 {
     $key = str_singular($model->getTable());
     if (!$model::$snakeAttributes) {
         $key = camel_case($key);
     }
     return $this->encode([$key => $model->toArray()]);
 }
開發者ID:joselfonseca,項目名稱:api,代碼行數:15,代碼來源:Json.php

示例15: pretendToRun

 /**
  * Pretend to run the migrations.
  *
  * @param  object  $migration
  * @param  string  $method
  *
  * @return void
  */
 protected function pretendToRun($migration, $method)
 {
     $table = $this->entity->getTable();
     $key = $this->entity->getKey();
     foreach ($this->getQueries($migration, $method) as $query) {
         $name = get_class($migration);
         $this->note("<info>{$name} [{$table}:{$key}]:</info> {$query['query']}");
     }
 }
開發者ID:DavidIWilson,項目名稱:site1,代碼行數:17,代碼來源:Migrator.php


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