PHPackages                             um-flint/laravel-repository - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. um-flint/laravel-repository

ActiveLibrary[Framework](/categories/framework)

um-flint/laravel-repository
===========================

A repository pattern for Laravel.

v4.0.0(3y ago)02.0kMITPHPPHP ^8.1

Since Oct 3Pushed 3y ago2 watchersCompare

[ Source](https://github.com/um-flint/laravel-repository)[ Packagist](https://packagist.org/packages/um-flint/laravel-repository)[ RSS](/packages/um-flint-laravel-repository/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (0)

Table of Contents
=================

[](#table-of-contents)

- [Methods](#methods)
    - [RepositoryInterface](#repository-interface)
    - [Traits](#traits)
        - [SoftDeletes](#soft-deletes)
- [Hooks](#hooks)
- [Validation](#validation)

Methods
-------------------------------------------

[](#methods-)

### UMFlint\\Repository\\Contracts\\RepositoryInterface

[](#umflintrepositorycontractsrepositoryinterface-)

- lists($column, $key = null)
- pluck($column, $key = null)
- sync($id, $relation, $attributes, $detaching = true)
- syncWithoutDetaching($id, $relation, $attributes)
- all($columns = \['\*'\])
- paginate($limit = null, $columns = \['\*'\])
- simplePaginate($limit = null, $columns = \['\*'\])
- find($id, $columns = \['\*'\])
- findByField($field, $value, $columns = \['\*'\])
- findWhere(array $where, $columns = \['\*'\])
- findWhereIn($field, array $values, $columns = \['\*'\])
- findWhereNotIn($field, array $values, $columns = \['\*'\])
- create(array $attributes)
- update(array $attributes, $id)
- delete($id)
- orderBy($column, $direction = 'asc')
- has($relation)
- with($relations)
- whereHas($relation, $closure)
- withCount($relations)
- hidden(array $fields)
- visible(array $fields)
- scopeQuery(\\Closure $scope)
- resetScope()

Traits
-----------------------------------------

[](#traits-)

### UMFlint\\Traits\\SoftDeletes

[](#umflinttraitssoftdeletes-)

This trait allows for soft deletes:

- delete($id, $force = false)

In order to query for deleted entities:

- withTrashed()

To restore a soft deleted entity:

- restore($id)

Hooks
---------------------------------------

[](#hooks-)

##### Boot

[](#boot)

Anything that needs to happen when the repository class is created. Uses Laravels container for automatic injection.

- boot()

##### Create

[](#create)

- beforeCreate(&amp;$attributes)
- afterCreate($model, &amp;$attributes)

##### Update

[](#update)

- beforeUpdate($model, &amp;$attributes)
- afterUpdate($model, &amp;$attributes)

##### Delete

[](#delete)

- beforeDelete($model)
- afterDelete($model, $deleted)

##### Restore

[](#restore)

- beforeRestore($model)
- afterRestore($model)

Validation
-------------------------------------------------

[](#validation-)

Example rules:

```
