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


PHP static::newQuery方法代碼示例

本文整理匯總了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;
 }
開發者ID:GlobalsDD,項目名稱:admin,代碼行數:10,代碼來源:SleepingOwlModel.php

示例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());
 }
開發者ID:badchoice,項目名稱:grog,代碼行數:13,代碼來源:SyncTrait.php

示例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);
 }
開發者ID:konversation,項目名稱:cuckoo,代碼行數:8,代碼來源:SlugTrait.php

示例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;
 }
開發者ID:basdog22,項目名稱:laracms,代碼行數:30,代碼來源:Lara.php

示例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();
 }
開發者ID:jbs321,項目名稱:affiliate-reporting-v1,代碼行數:15,代碼來源:AbstractModel.php

示例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);
 }
開發者ID:ghermans,項目名稱:openprovider-client,代碼行數:11,代碼來源:BaseModel.php

示例7: with

 public static function with($relations)
 {
     if (is_string($relations)) {
         $relations = func_get_args();
     }
     $instance = new static();
     return $instance->newQuery()->with($relations);
 }
開發者ID:noherczeg,項目名稱:restext,代碼行數:8,代碼來源:ResourceEloquentEntity.php

示例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);
 }
開發者ID:ithinkdancan,項目名稱:framework,代碼行數:21,代碼來源:TaxonomyTermModel.php

示例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);
 }
開發者ID:scmc,項目名稱:learninglocker,代碼行數:23,代碼來源:Client.php

示例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);
 }
開發者ID:khaliqgant,項目名稱:Deep,代碼行數:20,代碼來源:JoinableTrait.php

示例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();
 }
開發者ID:mikhailkozlov,項目名稱:rets-laravel,代碼行數:32,代碼來源:RetsField.php

示例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());
 }
開發者ID:lostcause,項目名稱:baum,代碼行數:14,代碼來源:Node.php

示例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;
 }
開發者ID:kjmtrue,項目名稱:laravel-nestedset,代碼行數:15,代碼來源:Node.php

示例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();
 }
開發者ID:kleitz,項目名稱:bjga-scheduler,代碼行數:11,代碼來源:Model.php

示例15: byUuid

 /**
  * @param string $uuid
  *
  * @return Card
  */
 public static function byUuid($uuid)
 {
     $instance = new static();
     $query = $instance->newQuery();
     return $query->where('uuid', $uuid)->firstOrFail();
 }
開發者ID:rupertjeff,項目名稱:ascension-card-db,代碼行數:11,代碼來源:Model.php


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