1. Controller:
If you do not relate to the database in the controller.
empty($res['code']) ? $this->error($res['msg']) : $this->success($res['msg']);
Thrown wording:
try{
$res = $Scoreflow->doaddscore($post);
if(empty($res['code'])){
throw new \Exception($res['msg']);
}
$this->success($res['msg']);
}catch(\Exception $e){
$this->error($e->getMessage());
}
2. Model:
All operations on the database are done in the model inside.
return [ 'code' => 0 | 1, 'msg' => 'return message']; // reply unified format will be the better deal