本文整理汇总了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());
}
}
示例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;
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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 = [];
}
示例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);
}
示例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);
}
}
示例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;
}
示例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));
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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()]);
}
示例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']}");
}
}