vinicius73/laravel-model-shield
Laravel Model Shield adds a lightweight protection layer around your Eloquent models, letting you guard sensitive attributes, control mass assignment and keep model data safe through simple, expressive configuration.
ModelShield is an attribute-protection layer for Eloquent models, and ShieldSentry is the adapter that lets you apply it to a Cartalyst Sentry User model without breaking Sentry's own authentication flow.
use Cartalyst\Sentry\Users\Eloquent\User as SentryModel;
use Vinicius73\ModelShield\Traits\ShieldSentry;
class User extends SentryModel
{
use ShieldSentry;
}
sentry.php config (users.model) resolves to the new App\User, otherwise you'll write shielded records that Sentry never reads back.Look first at the trait source and any config file — that's where the list of shielded fields and the hashing/encryption strategy is defined.
ShieldSentry pattern composes with Sentry's existing traits. Keep your Sentry model as the base and layer ModelShield on top; don't copy the vendor model into app/.password, persist_code, and reset_password_code. Use ModelShield only for fields Sentry doesn't already transform, so you don't double-hash a credential.text/string wide enough for ciphertext/base64 output — encrypted values are materially longer than plaintext.toArray()/toJson() models to clients, confirm shielded fields are still transformed (or explicitly $hidden) so you don't leak ciphertext or, worse, bypass the transform.ShieldSentry overrides attribute access. If you also use Sentry traits or your own getAttribute/setAttribute overrides, resolve collisions explicitly — call the parent or alias the trait. Silent shadowing is the most likely first bug.where('email', ...), LIKE searches, and unique-index semantics. Keep searchable/login fields (email, username) unshielded or maintain a separate deterministic hash column for lookups.APP_KEY (or a dedicated key). Rotating keys without a re-encryption pass will make existing shielded values unreadable. Treat key rotation as a migration, not a config change.DB::table() queries, raw selects). Always go through the model.composer.json and read the changelog before minor bumps; expect config keys and trait names to settle over time.DB::table('users')->...) and the model attribute in tinker — if only the raw value is encoded, the trait is working; if the model value is also encoded, your getter chain is misconfigured.How can I help you explore Laravel packages today?