本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::all方法的具体用法?PHP Model::all怎么用?PHP Model::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Defer loading of Collection until needed
* @return void
*/
protected function boot()
{
if (!is_null($this->collection)) {
return;
}
$this->collection = $this->model->all();
}
示例2: index
public function index()
{
$roles = $this->roleModel->all();
$permissions = $this->permissionService->getGroupedByControllerPermissions();
$roleCount = count($roles);
$rolePermissions = $this->roleService->getRolePermissions();
$activePermissions = $this->roleService->getRolePermissions();
return view('aliukevicius/laravelRbac::permissions.index', compact('roles', 'permissions', 'activePermissions', 'roleCount', 'rolePermissions'));
}
示例3: openSource
/**
* Open Eloquent Source
*
* @return bool
*/
public function openSource()
{
$this->source = $this->model;
// If specific collection not set then load all from table
if (!isset($this->collection)) {
$this->collection = $this->model->all();
}
return true;
}
示例4: getAll
/**
* @param array $with
* @throws \Symfony\Component\Process\Exception\InvalidArgumentException
* @return \Illuminate\Database\Eloquent\Collection|static[]
* wrapper for eloquent all();
*/
public function getAll($with = [])
{
if (isset($with) && !empty($with)) {
if (!is_array($with)) {
throw new InvalidArgumentException();
}
return $this->model->with($with)->get();
}
return $this->model->all();
}
示例5: listing
public static function listing()
{
$fractal = new Manager();
$data = new Collection(parent::all(), new GenreTransformer());
$list = $fractal->createData($data)->toArray()['data'];
return $list;
}
示例6: all
/**
* Get all of the models from the database.
*
* @param array|mixed $columns
* @return \Illuminate\Database\Eloquent\Collection|static[]
*/
public static function all($columns = ['*'])
{
if (func_num_args() === 0) {
$columns = self::fields();
}
return parent::all($columns);
}
示例7: all
/**
* @param array $columns
*
* @return mixed
*/
public function all($columns = ['*'])
{
$this->eagerLoading();
$this->applyCriteria();
$results = $this->model->all($columns);
$this->resetModel();
return $this->parseResult($results);
}
示例8: all
/**
* Retrieve all data of repository
*
* @param array $columns
* @return mixed
*/
public function all($columns = array('*'))
{
$this->applyCriteria();
if ($this->model instanceof \Illuminate\Database\Eloquent\Builder) {
$results = $this->model->get($columns);
} else {
$results = $this->model->all($columns);
}
return $this->parserResult($results);
}
示例9: json
/**
* Retrieve all data of modal.
*
* @param array $columns
*
* @return mixed
*/
public function json($columns = ['*'])
{
if ($this->model instanceof \Illuminate\Database\Eloquent\Builder) {
$results = $this->model->get($columns)->toArray();
} else {
$results = $this->model->all($columns)->toArray();
}
$this->resetModel();
return $results;
}
示例10: json
/**
* Retrieve all data of modal.
*
* @param array $columns
*
* @return mixed
*/
public function json($columns = ['*'])
{
if ($this->userFilter) {
$userId = User::users('id');
$results = $this->model->whereUserId($userId)->all($columns)->toArray();
} else {
$results = $this->model->all($columns)->toArray();
}
$this->resetModel();
return $results;
}
示例11: all
/**
* Retrieve all data of repository.
*
* @param array $columns
*
* @return mixed
*/
public function all($columns = ['*'])
{
$this->applyCriteria();
$this->applyScope();
if ($this->model instanceof \Illuminate\Database\Eloquent\Builder) {
$results = $this->model->get($columns);
} else {
$results = $this->model->all($columns);
}
$this->resetModel();
return $this->parserResult($results);
}
示例12: get
/**
* @param array $columns
* @return mixed
*/
public function get($columns = ['*'])
{
$this->applyBoot();
$this->applyScopes();
$this->applyCriteria();
if ($this->model instanceof Builder) {
$results = $this->model->get($columns);
} else {
$results = $this->model->all($columns);
}
$this->cleanRepository();
return $results;
}
示例13: checkDataValueForModel
/**
* Apply mutators to the attribute "value" for a specific GEDCOM data table.
*
* @param Model $entity
*/
private function checkDataValueForModel(Model $entity)
{
$this->info('Checking data values in table ' . $entity->getTable());
$entity->all()->each(function ($item) {
$old = $item->value;
$item->value = $old;
// Trigger the mutator
if ($item->isDirty()) {
$item->save();
$this->info('Fixing: ' . $old . ' -> ' . $item->value);
}
});
}
示例14: all
/**
* @param array $columns
*
* @return mixed
*/
public function all($columns = ['*'], $isCount = false)
{
$this->eagerLoading();
$this->applyCriteria();
if ($isCount) {
$results = $this->model->count();
} else {
$this->applyOrder();
if ($this->model instanceof Builder) {
$results = $this->model->get($columns);
} else {
$results = $this->model->all($columns);
}
}
$this->resetModel();
return $isCount ? $results : $this->parseResult($results);
}
示例15: browse
/**
* List
*
* @param array $options
* @return array
*/
public static function browse($options = [])
{
if (empty($options)) {
return parent::all();
}
if (!empty($options['order'])) {
foreach ($options['order'] as $field => $direction) {
$find = parent::orderBy($field, $direction);
}
}
if (!empty($options['limit'])) {
$find = $find->take($options['limit']);
}
if (!empty($options['cursor'])) {
$find = $find->where('id', '<', $options['cursor']);
}
return $find->get();
}