New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

michaelachrisco/readonly

Readonly Models for Laravel 5+
2,347,926 162
Install
composer require michaelachrisco/readonly
Latest Version:v1.1.0
PHP:>=7.0.0
License:MIT
Last Updated:Apr 2, 2026
Links: GitHub  ·  Packagist
Maintainer: michaelachrisco

Total Downloads build workflow Latest Version on Packagist

Laravel 5+ Read Only Models

The read only trait removes the ability to save, delete or modify Laravel models. Ideally, this would be used in addition to DB permissions to ensure users and developers cannot write to a Legacy system.

Install

composer require michaelachrisco/readonly

To use:

<?php
use Illuminate\Database\Eloquent\Model;
use MichaelAChrisco\ReadOnly\ReadOnlyTrait;
class User extends Model {
  use ReadOnlyTrait;
}

$legacyUser = new User;
$legacyUser->set_user_name('bob');

$result = $legacyUser->save();
//User is not saved. 
//ReadOnlyException is thrown.
 ?>

Methods that will throw ReadOnlyExceptions:

  • create
  • forceCreate
  • save
  • update
  • firstOrCreate
  • firstOrNew
  • delete
  • destroy
  • restore
  • forceDelete
  • performDeleteOnModel
  • push
  • finishSave
  • performUpdate
  • touch
  • insert
  • truncate
  • Add in a PR for any other methods you can find!

Related Packages

sofa/hookable

Laravel Eloquent hooks system.

2,050,959 65
volosyuk/simple-eloquent

Adaptation of eloquent for retrieving its attributes

117,926 55
gzero/eloquent-tree

Eloquent Tree is a tree model for Laravel Eloquent ORM.

59,533 131
martinbean/laravel-sluggable-trait

A trait you can apply to Eloquent models to have slugs automatically generated o...

49,126 24
isswp101/elasticsearch-eloquent

Elasticsearch functionality like Laravel Eloquent models.

25,593 112

Version History

Version Released PHP License
v1.1.0 >=7.0.0 MIT
v1.0.0 >=7.0.0 MIT
v0.60.1 >=7.0.0 MIT
v0.60.0 >=7.0.0 MIT
v0.50.0 >=7.0.0 MIT