本文整理汇总了PHP中static::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP static::fill方法的具体用法?PHP static::fill怎么用?PHP static::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createQuestion
public function createQuestion(Model $questionable, $data, Model $author)
{
$question = new static();
$question->fill(array_merge($data, ['author_id' => $author->id, 'author_type' => get_class($author)]));
$questionable->questions()->save($question);
return $question;
}
示例2: create
public static function create(array $attributes)
{
$model = new static();
$model->fill($attributes);
$model->save();
return $model;
}
示例3: createAnswer
public function createAnswer(Question $question, $data, Model $author)
{
$answer = new static();
$answer->fill(array_merge($data, ['author_id' => $author->id, 'author_type' => get_class($author)]));
$answer = $question->answers()->save($answer);
return $answer;
}
示例4: createRating
/**
* @param Model $ratingable
* @param $data
* @param Model $author
*
* @return static
*/
public function createRating(Model $ratingable, $data, Model $author)
{
$rating = new static();
$rating->fill(array_merge($data, ['author_id' => $author->id, 'author_type' => get_class($author)]));
$ratingable->ratings()->save($rating);
return $rating;
}
示例5: fromForm
/**
* Make a new photo instance from an uploaded file
*
* @var $file
* @return self
*/
public static function fromForm($file)
{
$photo = new static();
$photo->file = $file;
$photo->name = $photo->fileName();
return $photo->fill(['path' => $photo->filePath(), 'thumbnail_path' => $photo->thumbnailPath()]);
}
示例6: createReview
/**
* @param Model $reviewable
* @param $data
* @param Model $author
*
* @return static
*/
public function createReview(Model $reviewable, $data, Model $author)
{
$review = new static();
$review->fill(array_merge($data, ['author_id' => $author->id, 'author_type' => get_class($author)]));
$reviewable->reviews()->save($review);
return $review;
}
示例7: createComment
public function createComment(Model $commentable, $data, Model $creator)
{
$comment = new static();
$comment->fill(array_merge($data, ['creator_id' => $creator->id, 'creator_type' => get_class($creator)]));
$commentable->comments()->save($comment);
return $comment;
}
示例8: fromFileWithEvent
public static function fromFileWithEvent(UploadedFile $file, Event $event)
{
$photo = new static();
$photo->file = $file;
$photo->event = $event;
$photo->eventInfo = $photo->buildEventArray($photo->event->name, $photo->event->date_start);
return $photo->fill(['name' => $photo->fileName(), 'path' => $photo->filePath(), 'thumbnail_path' => $photo->thumbnailPath(), 'event_main' => 0]);
}
示例9: current
/**
* Retorna inquilino logado.
* @return Inquilino
*/
public static function current()
{
$model = new static();
$info = $model->getConnection()->get('/inquilino');
$model->fill((array) $info);
$model->syncOriginal();
return $model;
}
示例10: createFromFile
public static function createFromFile(File $file, AccountInterface $account)
{
$baseline = new static();
$baseline->fill($file->toArray());
$baseline->account_id = $account->id;
$baseline->save();
return $baseline;
}
示例11: init
/**
* @param array $attributes
* @return Model
*/
public static function init($attributes = [])
{
$model = new static(Di::getDefault()->get('mongo'), static::getDbName(), static::getSource());
if (count($attributes) > 0) {
$model->fill($attributes);
}
return $model;
}
示例12: assign
/**
* Assign a user to a project with a role
*
* @param int $user_id
* @param int $project_id
* @param int $role_id
* @return void
*/
public static function assign($user_id, $project_id, $role_id = 0)
{
if (!static::check_assign($user_id, $project_id)) {
$fill = array('user_id' => $user_id, 'project_id' => $project_id, 'role_id' => $role_id);
$relation = new static();
$relation->fill($fill);
$relation->save();
}
}
示例13: load
public static function load($id)
{
$page_content_file = static::get_content_directory() . '/' . $id . '.yml';
$page_content = file_get_contents($page_content_file);
$page_content_data = Yaml::parse($page_content);
$page = new static($id);
$page->fill($page_content_data);
return $page;
}
示例14: current
/**
* Get a new instance for the current user.
*
* @param null $fields
*
* @return static
*/
public static function current($fields = null)
{
global $USER;
$user = new static($USER->getId());
if (!is_null($fields)) {
$user->fill($fields);
}
return $user;
}
示例15: first
public function first()
{
$this->db->addQuery('LIMIT 1');
$data = $this->db->first();
if ($data) {
$model = new static();
$model->fill($data);
return $model;
}
return [];
}