2016-03-28 11:15:08 -07:00
|
|
|
<?php
|
2016-03-28 11:38:08 -07:00
|
|
|
namespace MichaelAChrisco\ReadOnly;
|
2017-03-31 11:28:20 -07:00
|
|
|
|
2016-12-09 07:19:04 -08:00
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
2017-03-27 13:14:50 -07:00
|
|
|
use MichaelAChrisco\ReadOnly\ReadOnlyException;
|
2016-12-09 07:19:04 -08:00
|
|
|
|
2017-03-31 11:28:20 -07:00
|
|
|
trait ReadOnlyTrait
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on create
|
|
|
|
* @param array $attributes
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public static function create(array $attributes = [])
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on forceCreate
|
|
|
|
* @param array $attributes
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public static function forceCreate(array $attributes)
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on save
|
|
|
|
* @param array $options
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public function save(array $options = [])
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on update
|
|
|
|
* @param array $attributes
|
|
|
|
* @param array $options
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public function update(array $attributes = [], array $options = [])
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on firstOrCreate
|
2018-10-22 14:00:30 -07:00
|
|
|
* @param array $attributes
|
|
|
|
* @param array $values
|
2017-12-11 14:10:25 -08:00
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2018-10-22 14:00:30 -07:00
|
|
|
public static function firstOrCreate(array $attributes, array $values = [])
|
2017-12-11 14:10:25 -08:00
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on firstOrNew
|
2018-10-22 14:00:30 -07:00
|
|
|
* @param array $attributes
|
|
|
|
* @param array $values
|
2017-12-11 14:10:25 -08:00
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2018-10-22 14:00:30 -07:00
|
|
|
public static function firstOrNew(array $attributes, array $values = [])
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on updateOrCreate
|
|
|
|
* @param array $attributes
|
|
|
|
* @param array $values
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public static function updateOrCreate(array $attributes, array $values = [])
|
2017-12-11 14:10:25 -08:00
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on delete
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on destroy
|
|
|
|
* @param mixed $ids
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public static function destroy($ids)
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on restore
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public function restore()
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on forceDelete
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
|
|
|
public function forceDelete()
|
|
|
|
{
|
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on performDeleteOnModel
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function performDeleteOnModel()
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2016-12-09 06:37:13 -08:00
|
|
|
}
|
|
|
|
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on push
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function push()
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2016-12-09 06:37:13 -08:00
|
|
|
}
|
|
|
|
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on finishSave
|
|
|
|
* @param array $options
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function finishSave(array $options)
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2016-12-09 06:37:13 -08:00
|
|
|
}
|
|
|
|
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on performUpdate
|
|
|
|
* @param Builder $query
|
|
|
|
* @param array $options
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function performUpdate(Builder $query, array $options = [])
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2016-12-09 06:37:13 -08:00
|
|
|
}
|
|
|
|
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on touch
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function touch()
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2016-12-09 06:37:13 -08:00
|
|
|
}
|
2017-03-31 10:58:44 -07:00
|
|
|
|
2017-12-11 14:10:25 -08:00
|
|
|
/**
|
|
|
|
* Throws ReadOnlyException on insert
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function insert()
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2017-03-29 10:15:48 -07:00
|
|
|
}
|
2017-03-31 10:58:44 -07:00
|
|
|
|
2017-03-29 10:15:48 -07:00
|
|
|
/**
|
2017-12-11 14:10:25 -08:00
|
|
|
* Throws ReadOnlyException on truncate
|
|
|
|
* @throws ReadOnlyException
|
|
|
|
*/
|
2017-03-31 11:28:20 -07:00
|
|
|
public function truncate()
|
|
|
|
{
|
2017-12-11 14:10:25 -08:00
|
|
|
throw new ReadOnlyException(__FUNCTION__, get_called_class());
|
2017-03-29 10:15:48 -07:00
|
|
|
}
|
2018-10-22 14:00:30 -07:00
|
|
|
}
|