本文整理汇总了PHP中Eloquent::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Eloquent::table方法的具体用法?PHP Eloquent::table怎么用?PHP Eloquent::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eloquent
的用法示例。
在下文中一共展示了Eloquent::table方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setModelObject
/**
* 设置 Model 类型对象
*
* @param Model $model
*/
public function setModelObject(Model $model)
{
$config = $model->getConnection();
self::$table = $config['tablename'];
$this->setConfig($config);
self::$model = $model;
}
示例2: filterQuery
/**
* Filters a query object
*
* @param Query $query
* @param Eloquent $model
*
* @return void
*/
public function filterQuery(&$query, $model)
{
//if the field is
if ($this->value !== '') {
$query->where($model->table() . '.' . $this->field, '=', $this->value);
}
}
示例3: constrainQuery
/**
* Constrains a query by a given set of constraints
*
* @param Query $query
* @param Eloquent $model
* @param array $constraints
*
* @return void
*/
public function constrainQuery(&$query, $model, $constraints)
{
//if the column hasn't been joined yet, join it
if (!Column::isJoined($query, $this->table)) {
$query->join($this->table, $model->table() . '.' . $model::$key, '=', $this->column2);
}
$query->where($this->column, '=', $constraints);
}
示例4: filterQuery
/**
* Adds selects to a query
*
* @param Query $query
* @param array $selects
* @param Eloquent $model
*
* @return void
*/
public function filterQuery(&$query, &$selects, $model)
{
//add the select statement
if ($this->select) {
//if this is a related field, we have to set up a fancy select because of issues with grouping
if ($this->isRelated) {
$where = '';
$fieldTable = $this->relationshipField->table;
switch ($this->relationshipField->type) {
case 'belongs_to':
$fieldTable = $this->field . '_' . $this->relationshipField->table;
$where = $model->table() . '.' . $this->relationshipField->foreignKey . ' = ' . $fieldTable . '.' . $this->relationshipField->column;
break;
case 'has_one':
case 'has_many':
$where = $model->table() . '.' . $model::$key . ' = ' . $fieldTable . '.' . $this->relationshipField->column;
break;
case 'has_many_and_belongs_to':
$where = $model->table() . '.' . $model::$key . ' = ' . $this->relationshipField->column;
break;
}
$selects[] = DB::raw("(SELECT " . $this->select . "\n\t\t\t\t\t\t\t\t\t\tFROM " . $this->relationshipField->table . " AS " . $fieldTable . "\n\t\t\t\t\t\t\t\t\t\tWHERE " . $where . ") AS " . $this->field);
} else {
$selects[] = DB::raw($this->select . ' AS ' . $this->field);
}
}
}
示例5: table
/**
* Get the table name
*
* @return string
*/
public function table()
{
$table = parent::table();
$table = $this->prefix ? $this->prefix . $table : $table;
return $table;
}