mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
31 lines
640 B
PHP
31 lines
640 B
PHP
<?php
|
|
|
|
namespace App\Classes\General\Eloquent;
|
|
|
|
use App\Classes\Exceptions\MalformedRequestException;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\QueryException;
|
|
|
|
abstract class AbstractDeleteRecord
|
|
{
|
|
|
|
/**
|
|
* @param Model $model
|
|
* @return mixed
|
|
* @throws MalformedRequestException
|
|
*/
|
|
public function handler(Model $model){
|
|
try{
|
|
|
|
if($model->delete()){
|
|
return [];
|
|
}
|
|
|
|
} catch (QueryException|\Exception $exception){
|
|
throw new MalformedRequestException('Unable to update the record due to unexpected error');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |