PHPackages                             chrisrhymes/policy-collect - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. chrisrhymes/policy-collect

ActiveProject[Authentication &amp; Authorization](/categories/authentication)

chrisrhymes/policy-collect
==========================

A Laravel Collection method to check a collection of models against a policy

v0.2(4y ago)106MitPHPCI failing

Since Feb 20Pushed 4y ago2 watchersCompare

[ Source](https://github.com/chrisrhymes/policy-collect)[ Packagist](https://packagist.org/packages/chrisrhymes/policy-collect)[ RSS](/packages/chrisrhymes-policy-collect/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Policy Collect
==============

[](#policy-collect)

Imagine you have a collection of models that you are returning via an ajax call, meaning you don't have access to the `@can` blade helpers to see whether the user should be able to view, update or delete each model.

This package offers a collection method that will go through a collection of models and check against the standard resource methods on the policy, returning whether the logged in user can perform an action. This can then be used in your JavaScript to decide which buttons to show or enable.

Installation
------------

[](#installation)

```
composer require chrisrhymes/policy-collect
```

Usage
-----

[](#usage)

For example, if the policy checks an order belongs to a user whether they can view the order and the first order does belong to the user then you can do the following:

```
$orders = Order::paginate()->policy();

echo $orders[0]->can->view; // true
```

### Resource Methods

[](#resource-methods)

It will return the standard policy methods by default

```
$orders[0]->can->view;
$orders[0]->can->update;
$orders[0]->can->delete;
$orders[0]->can->restore;
$orders[0]->can->forceDelete;
```

### Additional Policy Methods

[](#additional-policy-methods)

The policy collection method also allows you to pass in an array of custom methods to check these in your policy as well.

For example, if you had a refund method on your order policy to determine who can refund the order, which only allows admin users to refund you can do the following:

```
$orders = Order::paginate()->policy(['refund']);

echo $orders[0]->can->refund; // false
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~368 days

Total

3

Last Release

1535d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e30b61173703505b9c2cf784df20acbe3b564f97bae3e24803fad6af8a08b514?d=identicon)[chrisrhymes](/maintainers/chrisrhymes)

---

Top Contributors

[![chrisrhymes](https://avatars.githubusercontent.com/u/4160546?v=4)](https://github.com/chrisrhymes "chrisrhymes (5 commits)")

---

Tags

collectionlaravellaravel-collectionslaravel-packagelaravel6

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chrisrhymes-policy-collect/health.svg)

```
[![Health](https://phpackages.com/badges/chrisrhymes-policy-collect/health.svg)](https://phpackages.com/packages/chrisrhymes-policy-collect)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
