Initial commit

This commit is contained in:
omair saleh
2020-08-12 04:16:41 +08:00
commit 57bd2be885
476 changed files with 41783 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
namespace App\Classes\General\Abstracts;
use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Interfaces\DataTransferObject;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\QueryException;
abstract class AbstractService
{
/**
* @param Model $model
* @param DataTransferObject $object
* @return mixed
* @throws MalformedRequestException
*/
public function execute(Model $model, DataTransferObject $object){
try{
/** @var Model $model */
$model = $this->handler($model);
if($model->save()){
return $model;
}
} catch (QueryException $exception){
throw new MalformedRequestException('Unable to update the record due to unexpected error');
}
}
abstract function getModel(Model $model);
abstract function handler(Model $model);
}