当前位置: 首页>>代码示例>>PHP>>正文


PHP static::find方法代码示例

本文整理汇总了PHP中static::find方法的典型用法代码示例。如果您正苦于以下问题:PHP static::find方法的具体用法?PHP static::find怎么用?PHP static::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在static的用法示例。


在下文中一共展示了static::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findOrCreateBetween

 public static function findOrCreateBetween(\App\User $user, \App\User $other_user)
 {
     $user_participates = $user->privateConversations();
     $other_user_participates = $other_user->privateConversations();
     $static = new static();
     $shared_participations = collect(array_intersect($user_participates, $other_user_participates));
     return $shared_participations->isEmpty() ? $static->createBetween($user, $other_user) : $static->find($shared_participations->first());
 }
开发者ID:computerfr33k,项目名称:confer,代码行数:8,代码来源:Conversation.php

示例2: findCached

 /**
  * Find cached eloquent object
  * @param $id
  * @param $columns
  * @return Eloquent
  */
 public static function findCached($id, $columns = array('*'))
 {
     $instance = new static();
     $tableName = $instance->getTable();
     $eloquent = \Cache::remember($tableName . ':' . $id, static::$expireCache, function () use($id, $tableName, $instance, $columns) {
         return $instance->find($id, $columns);
     });
     return $eloquent;
 }
开发者ID:Metrakit,项目名称:dynamix,代码行数:15,代码来源:Eloquentizr.php

示例3: getSuppliersByBrand

 public static function getSuppliersByBrand($id, $includeThis = false)
 {
     $instance = new static();
     $brand = $instance->find($id);
     // TODO: Make Brand able to have many Suppliers.
     $supplier = Supplier::where('id', $brand->supplied_by)->first();
     if ($includeThis === true) {
         return array($supplier, $brand);
     }
     return array($supplier);
 }
开发者ID:johnny-human,项目名称:uhlelo,代码行数:11,代码来源:Supplier.php

示例4: forSelection

 /**
  * Helper method for creating select list options
  *
  * @param array $query
  * @return multitype:multitype:string NULL
  */
 public static function forSelection(array $query = array())
 {
     $model = new static();
     $items = $model->find($query);
     $result = array();
     foreach ($items as $doc) {
         $array = array('id' => (string) $doc['id'], 'text' => htmlspecialchars($doc['name'], ENT_QUOTES));
         $result[] = $array;
     }
     return $result;
 }
开发者ID:dioscouri,项目名称:f3-shop,代码行数:17,代码来源:ShippingMethods.php

示例5: findBySlug

 /**
  * @param string $slug
  * @param string $locale    optional, restrict search to given locale
  * @return mixed
  */
 public static function findBySlug($slug, $locale = null)
 {
     $model = new static();
     if ($model->storeSlugLocally()) {
         return $model::findBySlug($slug);
     }
     $id = $model->findRecordIdForSlugFromCmsTable($slug, $locale);
     // if it is translated, return by entry ID instead
     if ($model->isTranslationModel()) {
         return $model->where(config('pxlcms.translatable.translation_foreign_key'), $id)->first();
     }
     return $model->find($id);
 }
开发者ID:czim,项目名称:laravel-pxlcms,代码行数:18,代码来源:SluggableTrait.php

示例6: findAll

 public function findAll($asMap = false)
 {
     $tokenMappings = array();
     $bao = new static();
     $bao->find(false);
     while ($bao->fetch()) {
         if ($asMap) {
             $tokenMappings[$bao->mailchimp_token] = $bao->civicrm_token;
         } else {
             $tokenMappings[] = array('id' => $bao->id, 'civicrm_token' => $bao->civicrm_token, 'mailchimp_token' => $bao->mailchimp_token);
         }
     }
     return $tokenMappings;
 }
开发者ID:compucorp,项目名称:uk.co.compucorp.civicrm.mailchimp_converter,代码行数:14,代码来源:TokenMapping.php

示例7: defaultData

 public function defaultData()
 {
     if (isset(static::$db_defaultdata)) {
         foreach (static::$db_defaultdata as $k => $d) {
             $obj = new static();
             if (!$obj->find($d[0])) {
                 $obj->{static::$db_idcolumn} = $d[0];
                 foreach (static::$db_columns as $ci => $c) {
                     $obj->{$c[0]} = $d[$ci + 1];
                 }
                 $obj->save();
             }
         }
     }
 }
开发者ID:graftphp,项目名称:framework,代码行数:15,代码来源:Model.php

示例8: add

 /**
  * Add the mailings.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Reference array contains the id.
  *
  *
  * @return CRM_Mailing_DAO_Mailing
  */
 public static function add(&$params, $ids = array())
 {
     $id = CRM_Utils_Array::value('mailing_id', $ids, CRM_Utils_Array::value('id', $params));
     if ($id) {
         CRM_Utils_Hook::pre('edit', 'Mailing', $id, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Mailing', NULL, $params);
     }
     $mailing = new static();
     if ($id) {
         $mailing->id = $id;
         $mailing->find(TRUE);
     }
     $mailing->domain_id = CRM_Utils_Array::value('domain_id', $params, CRM_Core_Config::domainID());
     if (!isset($params['replyto_email']) && isset($params['from_email'])) {
         $params['replyto_email'] = $params['from_email'];
     }
     $mailing->copyValues($params);
     $result = $mailing->save();
     if (!empty($ids['mailing'])) {
         CRM_Utils_Hook::post('edit', 'Mailing', $mailing->id, $mailing);
     } else {
         CRM_Utils_Hook::post('create', 'Mailing', $mailing->id, $mailing);
     }
     return $result;
 }
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:37,代码来源:Mailing.php

示例9: findById

 /**
  * Find a DAO object for the given ID and return it.
  *
  * @param int $id
  *   Id of the DAO object being searched for.
  *
  * @return object
  *   Object of the type of the class that called this function.
  */
 public static function findById($id)
 {
     $object = new static();
     $object->id = $id;
     if (!$object->find(TRUE)) {
         throw new Exception("Unable to find a " . get_called_class() . " with id {$id}.");
     }
     return $object;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:18,代码来源:DAO.php

示例10: getAll

 public static function getAll($opts = array())
 {
     $c = new static();
     return $c->find(array(), $opts);
 }
开发者ID:RobertoPiccinato,项目名称:web,代码行数:5,代码来源:Mapper.php

示例11: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'add_item':
             $input = $ma->getInput();
             $item_ticket = new static();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && !empty($input['items_id'])) {
                     $input['tickets_id'] = $id;
                     $input['itemtype'] = $input['item_itemtype'];
                     if ($item_ticket->can(-1, CREATE, $input)) {
                         $ok = true;
                         if (!$item_ticket->add($input)) {
                             $ok = false;
                         }
                         if ($ok) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
         case 'delete_item':
             $input = $ma->getInput();
             $item_ticket = new static();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id) && !empty($input['items_id'])) {
                     $item_found = $item_ticket->find("`tickets_id` = {$id} AND `itemtype` = '" . $input['item_itemtype'] . "' AND `items_id` = " . $input['items_id']);
                     if (!empty($item_found)) {
                         $item_founds_id = array_keys($item_found);
                         $input['id'] = $item_founds_id[0];
                         if ($item_ticket->can($input['id'], DELETE, $input)) {
                             $ok = true;
                             if (!$item_ticket->delete($input)) {
                                 $ok = false;
                             }
                             if ($ok) {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                             } else {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                             $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:korial29,项目名称:glpi,代码行数:73,代码来源:item_ticket.class.php

示例12: getGroups

 /**
  * Get groups
  *
  * @static
  * @access public
  * @param  Client    $client
  * @param  string    $query
  * @return LdapGroupProvider[]
  */
 public static function getGroups(Client $client, $query)
 {
     $self = new static(new Query($client));
     return $self->find($query);
 }
开发者ID:rammstein4o,项目名称:kanboard,代码行数:14,代码来源:Group.php

示例13: create

 public static function create($columns)
 {
     $instance = new static();
     foreach ($columns as $k => $v) {
         $instance->{$k} = $v;
     }
     $create = $instance->zuora()->create([$instance->castToZuora()]);
     $instance->throwExceptionOnError($create);
     return $instance->find($create->result->Id);
 }
开发者ID:olivierbarbier,项目名称:zuora-orm,代码行数:10,代码来源:Base.php

示例14: getUser

 /**
  * Get user profile
  *
  * @static
  * @access public
  * @param  Client    $client
  * @param  string    $username
  * @return LdapUserProvider
  */
 public static function getUser(Client $client, $username)
 {
     $self = new static(new Query($client), new Group(new Query($client)));
     return $self->find($self->getLdapUserPattern($username));
 }
开发者ID:rammstein4o,项目名称:kanboard,代码行数:14,代码来源:User.php


注:本文中的static::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。