當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。