本文整理汇总了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());
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
}
}
示例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;
}
示例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;
}
示例10: getAll
public static function getAll($opts = array())
{
$c = new static();
return $c->find(array(), $opts);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}