mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
32 lines
632 B
PHP
32 lines
632 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 $model
|
|
* @return Model
|
|
* @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');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |