mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/tickme.git
synced 2026-08-28 17:04:09 +00:00
31 lines
642 B
PHP
31 lines
642 B
PHP
<?php
|
|
|
|
namespace App\Classes\General\Eloquent;
|
|
|
|
use App\Classes\Exceptions\MalformedRequestException;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\QueryException;
|
|
|
|
abstract class AbstractUpdateRecord
|
|
{
|
|
|
|
|
|
/**
|
|
* @param Model|null $model
|
|
* @return Model|null
|
|
* @throws MalformedRequestException
|
|
*/
|
|
public function handler(?Model $model){
|
|
try{
|
|
if($model->save()){
|
|
return $model;
|
|
}
|
|
|
|
} catch (QueryException $exception){
|
|
throw new MalformedRequestException('Unable to update the record due to unexpected error');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |