本文整理汇总了PHP中static::newQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP static::newQuery方法的具体用法?PHP static::newQuery怎么用?PHP static::newQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::newQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: withoutOrders
/**
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function withoutOrders()
{
$instance = new static();
$query = $instance->newQuery();
$query->getQuery()->orders = [];
return $query;
}
示例2: sync
public static function sync($fromDate = '')
{
$instance = new static();
$newQuery = static::syncFilter($instance->newQuery()->where(function ($query) use(&$fromDate) {
$query->where('created_at', '>', $fromDate)->orWhereNull('created_at');
}));
$updateQuery = static::syncFilter($instance->newQuery()->where('updated_at', '>', $fromDate)->where('created_at', '<', $fromDate));
$deleteQuery = static::syncFilter($instance->newQuery()->onlyTrashed()->where('deleted_at', '>', $fromDate));
if ($fromDate == '') {
return array('new' => $newQuery->get()->toArray(), 'updated' => null, 'deleted' => null);
}
return array('new' => $newQuery->get()->toArray(), 'updated' => $updateQuery->get()->toArray(), 'deleted' => $deleteQuery->get()->toArray());
}
示例3: findBySlug
public static function findBySlug($slug, $columns = ['*'])
{
$instance = new static();
if (is_array($slug)) {
return $instance->newQuery()->whereIn('slug', $slug)->get($columns);
}
return $instance->newQuery()->slug($slug)->get($columns);
}
示例4: find
public static function find($id, $columns = array('*'))
{
if (is_array($id) && empty($id)) {
return new Collection();
}
$instance = new static();
$obj = $instance->newQuery()->find($id, $columns);
if (is_array($id)) {
$prop = new ReflectionProperty(get_class($obj), 'items');
}
$col = array();
if (isset($prop->name)) {
$prop->setAccessible(1);
foreach ($prop->getValue($obj) as $k => $object) {
$translation = Translations::find($object->table . "_" . $object->id . "_" . strtolower(Config::get('cms.currlang.code')));
$object->setRawAttributes(json_decode($translation->translation, 1));
$col[] = $object;
}
$prop->setValue($obj, $col);
} else {
$translation = Translations::find($obj->table . "_" . $obj->id . "_" . strtolower(Config::get('cms.currlang.code')));
$obj->setRawAttributes(json_decode($translation->translation, 1));
$seo = $obj->seo()->first();
if (!is_null($seo)) {
Config::set('cms.seo', $seo);
}
}
//
return $obj;
}
示例5: findBy
/**
* Find a model by its primary key.
* @param string $name
* @param mixed $key
* @param array $columns
* @return \Illuminate\Support\Collection|static|null
*/
public static function findBy($name, $key, $columns = array('*'))
{
$instance = new static();
if (is_array($key) && empty($key)) {
return $instance->newCollection();
}
return $instance->newQuery()->where($name, '=', $key)->get();
}
示例6: __callStatic
/**
* {@inheritDoc}
*/
public static function __callStatic($method, $parameters)
{
$instance = new static();
if (in_array($method, array_keys($instance->paths))) {
return $instance->newQuery()->from($instance->getPath($method));
}
return call_user_func_array(array($instance, $method), $parameters);
}
示例7: with
public static function with($relations)
{
if (is_string($relations)) {
$relations = func_get_args();
}
$instance = new static();
return $instance->newQuery()->with($relations);
}
示例8: all
/**
* Get all of the models from the database. Overrides the base behavior to
* add the category slug as a condition.
*
* @param array $columns
* An array of columns to access.
*
* @return \Illuminate\Database\Eloquent\Collection|static[]
*/
public static function all($columns = ['*'])
{
// If there's a defined taxonomy slug, attach that.
$instance = new static();
if (isset($instance->taxonomy_slug) && $instance->taxonomy_slug) {
// Return a constrained collection.
$columns = is_array($columns) ? $columns : func_get_args();
return $instance->newQuery()->where('taxonomy', $instance->taxonomy_slug)->get($columns);
}
// Return the parent's behavior, if nothing is set.
return parent::all($columns);
}
示例9: where
/**
* Add a basic where clause to the client query.
* Normally, Illuminate\Database\Eloquent\Model handles this method (through __call()).
* This implementation converts foreign ids from strings to MongoIds.
*
* @param string $column
* @param string $operator
* @param mixed $value
* @param string $boolean
* @return Jenssegers\Mongodb\Eloquent\Builder
*/
public static function where($column, $operator = null, $value = null, $boolean = 'and')
{
if (func_num_args() == 2) {
list($value, $operator) = array($operator, '=');
}
if ($column == 'lrs_id') {
$value = new \MongoId($value);
}
$instance = new static();
$query = $instance->newQuery();
return $query->where($column, $operator, $value, $boolean);
}
示例10: find
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array $columns
* @return \Illuminate\Database\Eloquent\Model|Collection
*/
public static function find($id, $columns = array('*'))
{
$instance = new static();
if (is_array($id) && empty($id)) {
return $instance->newCollection();
}
$query = $instance->newQuery();
$key = $instance->table . '.' . $instance->primaryKey;
if (is_array($id)) {
return $query->whereIn($key, $id)->get($columns);
}
return $query->where($key, '=', $id)->first($columns);
}
示例11: createFromXml
/**
*
* Method designed to save XML data into a table
*
* @param SimpleXMLElement $fieldData
*
* @return \Illuminate\Support\Collection
*/
public static function createFromXml(\SimpleXMLElement $fieldData)
{
$instance = new static();
if (!is_null($fieldData->attributes())) {
foreach ($fieldData->attributes() as $k => $v) {
if ($k == 'Resource') {
$instance->resource = $v;
}
if ($k == 'Lookup') {
$instance->lookup_id = $v;
}
}
}
$lookup = (array) $fieldData->xpath('Lookup');
foreach ($lookup as $field) {
$instance->exists = false;
$field = (array) $field;
$instance->id = $field['Value'];
$instance->long = $field['LongValue'];
$instance->short = $field['ShortValue'];
$instance->save();
}
return $instance->newQuery()->where('lookup_id', $instance->lookup_id)->where('resource', $instance->resource)->get();
}
示例12: allTrunks
/**
* Static query scope. Returns a query scope with all nodes which are at
* the middle of a branch (not root and not leaves).
*
* @return \Illuminate\Database\Query\Builder
*/
public static function allTrunks()
{
$instance = new static();
$grammar = $instance->getConnection()->getQueryGrammar();
$rgtCol = $grammar->wrap($instance->getQualifiedRightColumnName());
$lftCol = $grammar->wrap($instance->getQualifiedLeftColumnName());
return $instance->newQuery()->whereNotNull($instance->getParentColumnName())->whereRaw($rgtCol . ' - ' . $lftCol . ' != 1')->orderBy($instance->getQualifiedOrderColumnName());
}
示例13: fixTree
/**
* Fixes the tree based on parentage info.
*
* Requires at least one root node. This will not update nodes with invalid parent.
*
* @return int The number of fixed nodes.
*/
public static function fixTree()
{
$model = new static();
$columns = [$model->getKeyName(), $model->getParentIdName(), $model->getLftName(), $model->getRgtName()];
$nodes = $model->newQuery()->defaultOrder()->get($columns)->groupBy($model->getParentIdName());
self::reorderNodes($nodes, $fixed);
return $fixed;
}
示例14: startQuery
/**
* Kick off a new query.
*
* @return Builder
*/
public static function startQuery()
{
// Get a new instance of the model
$instance = new static();
return $instance->newQuery();
}
示例15: byUuid
/**
* @param string $uuid
*
* @return Card
*/
public static function byUuid($uuid)
{
$instance = new static();
$query = $instance->newQuery();
return $query->where('uuid', $uuid)->firstOrFail();
}