Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michaelachrisco/readonlytraitlaravel
Laravel Read Only Model Traits
https://github.com/michaelachrisco/readonlytraitlaravel
eloquent eloquent-models laravel laravel-5-package laravel-model laravel-models laravel-read php read-only-laravel
Last synced: 6 days ago
JSON representation
Laravel Read Only Model Traits
- Host: GitHub
- URL: https://github.com/michaelachrisco/readonlytraitlaravel
- Owner: michaelachrisco
- License: mit
- Created: 2016-03-28T18:13:20.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-06-18T16:50:05.000Z (8 months ago)
- Last Synced: 2025-01-25T01:38:22.308Z (13 days ago)
- Topics: eloquent, eloquent-models, laravel, laravel-5-package, laravel-model, laravel-models, laravel-read, php, read-only-laravel
- Language: PHP
- Homepage: https://github.com/michaelachrisco/ReadOnlyTraitLaravel
- Size: 46.9 KB
- Stars: 151
- Watchers: 4
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Total Downloads](https://img.shields.io/packagist/dt/michaelachrisco/readonly.svg)](https://packagist.org/packages/michaelachrisco/readonly)
![build workflow](https://github.com/michaelachrisco/ReadOnlyTraitLaravel/actions/workflows/build.yml/badge.svg)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/michaelachrisco/readonly.svg)](https://packagist.org/packages/michaelachrisco/readonly)# 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
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!###