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


PHP Model::first方法代码示例

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


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

示例1: first

 /**
  * Retrieve first data of repository
  *
  * @param array $columns
  *
  * @return mixed
  */
 public function first($columns = ['*'])
 {
     $this->applyCriteria();
     $this->applyScope();
     $results = $this->model->first($columns);
     $this->resetModel();
     return $this->parserResult($results);
 }
开发者ID:mammutgroup,项目名称:l5-repository,代码行数:15,代码来源:BaseRepository.php

示例2: sendResetPasswordEmail

 /**
  * Generate and send a email with reset password instructions.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @param  array $conditions WHERE conditions to locate user. Format: ['column' => 'value']
  * @return bool
  * @throws \Nodes\Backend\Auth\Exception\ResetPasswordNoUserException
  */
 public function sendResetPasswordEmail(array $conditions)
 {
     // Validate conditions
     if (empty($conditions)) {
         return false;
     }
     // Add conditions to query builder
     foreach ($conditions as $column => $value) {
         $this->userModel = $this->userModel->where($column, '=', $value);
     }
     // Retrieve user with conditions
     $user = $this->userModel->first();
     if (empty($user)) {
         $this->errors->add('no-user-found', 'Could not find any user with those credentials.');
         return false;
     }
     // Generate reset password token
     $token = $this->generateResetPasswordToken($user);
     // Send e-mail with instructions on how to reset password
     \Mail::send(['html' => config('nodes.backend.reset-password.views.html', 'nodes.backend::reset-password.emails.html'), 'text' => config('nodes.backend.reset-password.views.text', 'nodes.backend::reset-password.emails.text')], ['user' => $user, 'domain' => config('app.url'), 'token' => $token, 'expire' => config('nodes.backend.reset-password.expire', 60), 'project' => config('nodes.project.name')], function ($message) use($user) {
         $message->to($user->email)->from(config('nodes.backend.reset-password.from.email', 'no-reply@nodes.dk'), config('nodes.backend.reset-password.from.name', 'Nodes'))->subject(config('nodes.backend.reset-password.subject', 'Reset password request'));
     });
     return true;
 }
开发者ID:nodes-php,项目名称:backend,代码行数:33,代码来源:ResetPasswordRepository.php

示例3: sendResetPasswordEmail

 /**
  * Generate and send a email with reset password instructions.
  *
  * @author Morten Rugaard <moru@nodes.dk>
  *
  * @param  array $conditions WHERE conditions to locate user. Format: ['column' => 'value']
  * @throws \Nodes\Api\Auth\Exceptions\ResetPasswordNoUserException
  */
 public function sendResetPasswordEmail(array $conditions)
 {
     // Validate conditions
     if (empty($conditions)) {
         throw new ResetPasswordNoUserException('Conditions can\'t be empty');
     }
     // Add conditions to query builder
     foreach ($conditions as $column => $value) {
         $this->authModel = $this->authModel->where($column, '=', $value);
     }
     // Retrieve user with conditions
     $user = $this->authModel->first();
     if (empty($user)) {
         throw new ResetPasswordNoUserException('Could not find any user with those credentials');
     }
     // Generate reset password token
     $token = $this->generateResetPasswordToken($user);
     // Generate reset password domain
     $domain = env('NODES_ENV', false) ? sprintf('https://%s.%s', env('APP_NAME'), env('APP_DOMAIN')) : config('app.url');
     // Send e-mail with instructions on how to reset password
     Mail::send(['html' => config('nodes.api.reset-password.views.html', 'nodes.api::reset-password.emails.html'), 'text' => config('nodes.api.reset-password.views.text', 'nodes.api::reset-password.emails.text')], ['user' => $user, 'domain' => $domain, 'token' => $token, 'expire' => config('nodes.api.reset-password.expire'), 'senderName' => config('nodes.api.reset-password.from.name') != 'Nodes' ? config('nodes.api.reset-password.from.name') : config('nodes.project.name')], function ($message) use($user) {
         $message->to($user->email)->from(config('nodes.api.reset-password.from.email', 'no-reply@nodes.dk'), config('nodes.api.reset-password.from.name', 'Nodes'))->subject(config('nodes.api.reset-password.subject', 'Reset password request'));
     });
 }
开发者ID:nodes-php,项目名称:api,代码行数:32,代码来源:ResetPasswordRepository.php

示例4: extractModelAndKeys

 /**
  * Extract the model instance and model keys from the given parameters.
  *
  * @param  string|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection  $model
  * @param  array|null  $keys
  * @return array
  */
 public static function extractModelAndKeys($model, array $keys = null)
 {
     if (is_null($keys)) {
         if ($model instanceof Model) {
             return [$model, [$model->getKey()]];
         }
         if ($model instanceof Collection) {
             return [$model->first(), $model->modelKeys()];
         }
     } else {
         if (is_string($model)) {
             $model = new $model();
         }
         return [$model, $keys];
     }
 }
开发者ID:JosephSilber,项目名称:bouncer,代码行数:23,代码来源:Helper.php

示例5: first

 /**
  * Returns the first record in the database.
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function first()
 {
     return $this->model->first();
 }
开发者ID:vinelab,项目名称:lucid,代码行数:9,代码来源:Repository.php


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