@ -147,7 +147,7 @@ class EmailTemplateController extends BaseController
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = $this->model->find($all['id']);
$detail = $this->model->withCount('emailRecords')->find($all['id']);
return $this->success($detail);
@ -9,5 +9,10 @@ use Illuminate\Support\Facades\Cache;
class EmailTemplate extends SoftDeletesModel
{
public function emailRecords()
return $this->hasMany(EmailRecord::class, 'email_template_id', 'id');