当前位置: 首页>>代码示例>>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;未经允许,请勿转载。