修复编码风格

main
Jing Li 2024-05-20 10:14:15 +08:00
parent 8a317876e0
commit 6b94eec365
127 changed files with 624 additions and 520 deletions

View File

@ -41,6 +41,7 @@ abstract class AdminController extends Controller
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
return $this->renderException($th);
}
@ -70,6 +71,7 @@ abstract class AdminController extends Controller
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
return $this->renderException($th);
}
@ -92,6 +94,7 @@ abstract class AdminController extends Controller
DB::commit();
} catch (Throwable $th) {
DB::rollBack();
return $this->renderException($th);
}

View File

@ -3,15 +3,16 @@
namespace App\Admin\Controllers;
use App\Admin\Services\AgreementService;
use App\Enums\CheckStatus;
use App\Enums\EmployeeStatus;
use App\Models\Agreement;
use App\Traits\HasCheckActions;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\{Storage};
use Illuminate\Support\{Arr};
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\{EmployeeStatus, CheckStatus};
use App\Models\Agreement;
use Illuminate\Support\{Arr};
use Illuminate\Support\Facades\{Storage};
use Illuminate\Http\Request;
use App\Traits\HasCheckActions;
/**
* 合同管理
@ -71,7 +72,7 @@ class AgreementController extends AdminController
->label('打包下载')
->api(admin_url('agreement/download?id=${id}'))
->level('link')
->redirect(url('admin-api/_download_export') . '?path=${path}')
->redirect(url('admin-api/_download_export').'?path=${path}')
->visibleOn('${ARRAYINCLUDES(row_actions, "download")}'),
]),
]);
@ -90,7 +91,7 @@ class AgreementController extends AdminController
->searchable()
->required(),
amisMake()->ImageControl()->name('images')->label(__('agreement.images'))
->receiver(admin_url('upload_image') . '?full-url=1')
->receiver(admin_url('upload_image').'?full-url=1')
->multiple()
->draggable()
->joinValues(false),
@ -131,20 +132,21 @@ class AgreementController extends AdminController
public function download(Request $request)
{
$model = Agreement::findOrFail($request->input('id'));
if (!$model->images || count($model->images) == 0) {
if (! $model->images || count($model->images) == 0) {
return $this->response()->fail('没有图片下载');
}
$zip = new \ZipArchive();
$filename = time().'.zip';
$filepath = storage_path('app/' . $filename);
$filepath = storage_path('app/'.$filename);
$zip->open($filepath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
$baseUrl = Storage::disk('public')->url('');
foreach($model->images as $item) {
foreach ($model->images as $item) {
$path = str_replace($baseUrl, '', $item);
$info = pathinfo($path);
$zip->addFile(Storage::disk('public')->path($path), data_get($info, 'basename'));
}
$zip->close();
return $this->response()->success(['path' => $filename]);
}
}

View File

@ -2,7 +2,6 @@
namespace App\Admin\Controllers;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\AppVersionService;
use App\Enums\AppOs;
use App\Enums\AppUpdateStrategy;

View File

@ -62,8 +62,7 @@ class CockpitController extends Controller
$endAt = $today->copy()->subDay();
return $statisticService->dailyLedgerTrend($startAt, $endAt);
}
elseif (in_array($last, ['180days', '365days'])) {
} elseif (in_array($last, ['180days', '365days'])) {
// 按月
$months = match ($last) {
'180days' => 6, // 6个月
@ -134,6 +133,7 @@ class CockpitController extends Controller
'date' => $date,
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
return [
'id' => $lotteryType->key,
'name' => $lotteryType->name,
@ -144,8 +144,7 @@ class CockpitController extends Controller
$startAt->addDay();
}
}
elseif (in_array($last, ['180days', '365days'])) {
} elseif (in_array($last, ['180days', '365days'])) {
// 按月
$months = match ($last) {
'180days' => 6, // 6个月
@ -170,7 +169,7 @@ class CockpitController extends Controller
->get()
->groupBy('month');
for ($i=0; $i < $months; $i++) {
for ($i = 0; $i < $months; $i++) {
$month = $startAt->format('Y-m');
$lotteryTypeLedgerItems = $lotteryTypeLedgers->get($month, collect())->keyBy('ledger_item_type_id');
@ -179,6 +178,7 @@ class CockpitController extends Controller
'month' => $month,
'data' => $lotteryTypes->map(function ($lotteryType) use ($lotteryTypeLedgerItems) {
$lotteryTypeLedgerItem = $lotteryTypeLedgerItems->get($lotteryType->key);
return [
'id' => $lotteryType->key,
'name' => $lotteryType->name,

View File

@ -93,7 +93,6 @@ class CommissionIncomeController extends AdminController
* 导出按钮
*
* @param bool $disableSelectedItem
*
* @return \Slowlyo\OwlAdmin\Renderers\Service
*/
protected function exportAction($disableSelectedItem = false)
@ -103,7 +102,7 @@ class CommissionIncomeController extends AdminController
// 导出接口地址
$exportPath = $this->getExportPath();
// 按钮点击事件
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
// 导出处理动作
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
// 按钮
@ -130,7 +129,7 @@ class CommissionIncomeController extends AdminController
*/
protected function export()
{
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
// 默认在 storage/app/ 下
$path = sprintf('佣金收入-%s.xlsx', date('YmdHis'));
@ -138,7 +137,7 @@ class CommissionIncomeController extends AdminController
$data = [$this->getCommissionIncomeStatistics()];
try {
fastexcel($data)->export(storage_path('app/' . $path), fn($row) => [
fastexcel($data)->export(storage_path('app/'.$path), fn ($row) => [
'预期佣金' => $row['expected_commission'],
'实际佣金' => $row['actual_commission'],
'佣金差异' => $row['diff_commission'],

View File

@ -89,12 +89,12 @@ class SalesStatisticController extends AdminController
'name' => $lotteryType->name,
'sales' => trim_zeros($statistic->sales ?? '0.00'),
'expenditure' => trim_zeros($statistic->expenditure ?? '0.00'),
'real_sales' => match($lotteryType->value) {
'real_sales' => match ($lotteryType->value) {
'+' => $statistic->sales ?? '0.00',
'-' => -($statistic->sales ?? '0.00'),
default => 0,
},
'real_expenditure' => match($lotteryType->value) {
'real_expenditure' => match ($lotteryType->value) {
'+' => $statistic->expenditure ?? '0.00',
'-' => -($statistic->expenditure ?? '0.00'),
default => 0,
@ -107,7 +107,6 @@ class SalesStatisticController extends AdminController
* 导出按钮
*
* @param bool $disableSelectedItem
*
* @return \Slowlyo\OwlAdmin\Renderers\Service
*/
protected function exportAction($disableSelectedItem = false)
@ -117,7 +116,7 @@ class SalesStatisticController extends AdminController
// 导出接口地址
$exportPath = $this->getExportPath();
// 按钮点击事件
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
// 导出处理动作
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
// 按钮
@ -144,7 +143,7 @@ class SalesStatisticController extends AdminController
*/
protected function export()
{
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
// 默认在 storage/app/ 下
$path = sprintf('销售统计-%s.xlsx', date('YmdHis'));
@ -152,7 +151,7 @@ class SalesStatisticController extends AdminController
$data = $this->getLotteryTypeStatistics();
try {
fastexcel($data)->export(storage_path('app/' . $path), fn($row) => [
fastexcel($data)->export(storage_path('app/'.$path), fn ($row) => [
'彩种' => $row['name'],
'销量' => $row['sales'],
'兑奖' => $row['expenditure'],

View File

@ -72,7 +72,6 @@ class StoreStatisticController extends AdminController
* 导出按钮
*
* @param bool $disableSelectedItem
*
* @return \Slowlyo\OwlAdmin\Renderers\Service
*/
protected function exportAction($disableSelectedItem = false)
@ -82,7 +81,7 @@ class StoreStatisticController extends AdminController
// 导出接口地址
$exportPath = $this->getExportPath();
// 按钮点击事件
$event = fn($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
$event = fn ($script) => ['click' => ['actions' => [['actionType' => 'custom', 'script' => $script]]]];
// 导出处理动作
$doAction = "doAction([{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:true}}},{actionType:'ajax',args:{api:{url:url.toString(),method:'get'}}},{actionType:'setValue',componentId:'export-action',args:{value:{showExportLoading:false}}},{actionType:'custom',expression:'\${event.data.responseResult.responseStatus===0}',script:'window.open(\'{$downloadPath}?path=\'+event.data.responseResult.responseData.path)'}])";
// 按钮
@ -109,7 +108,7 @@ class StoreStatisticController extends AdminController
*/
protected function export()
{
admin_abort_if(!class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
admin_abort_if(! class_exists('\Rap2hpoutre\FastExcel\FastExcel'), __('admin.export.please_install_laravel_excel'));
// 默认在 storage/app/ 下
$path = sprintf('门店统计-%s.xlsx', date('YmdHis'));
@ -117,7 +116,7 @@ class StoreStatisticController extends AdminController
$data = $this->getStoreRanking();
try {
fastexcel($data)->export(storage_path('app/' . $path), function($row) {
fastexcel($data)->export(storage_path('app/'.$path), function ($row) {
return [
'排序' => $row['ranking'],
'门店' => Arr::get($row, 'store.title'),

View File

@ -6,7 +6,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Resources\Json\JsonResource;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use Slowlyo\OwlAdmin\Renderers\Action;
use Slowlyo\OwlAdmin\Renderers\Card;
use Slowlyo\OwlAdmin\Renderers\Chart;
use Slowlyo\OwlAdmin\Renderers\Custom;

View File

@ -127,6 +127,7 @@ class EmployeeController extends AdminController
if ($this->service->leave($user, $request->only(['leave_at']))) {
return $this->response()->success(null, '操作成功');
}
return $this->response()->fail($this->service->getError());
}
@ -143,6 +144,7 @@ class EmployeeController extends AdminController
protected function exportMap($row)
{
$jobs = data_get($row, 'jobs', []);
return [
__('employee.id') => data_get($row, 'id'),
__('employee.name') => data_get($row, 'name'),

View File

@ -4,7 +4,9 @@ namespace App\Admin\Controllers\Hr;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\EmployeePromotionService;
use App\Enums\{EmployeeStatus, CheckStatus, PromotionStatus};
use App\Enums\CheckStatus;
use App\Enums\EmployeeStatus;
use App\Enums\PromotionStatus;
use App\Traits\HasCheckActions;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Form;

View File

@ -289,7 +289,7 @@ class PlanController extends AdminController
->icon('fa fa-send-o')
->level('link')
->confirmText('是否发布选中的任务计划?')
->api('post:' . admin_url('/plan/plans/${id}/publish'));
->api('post:'.admin_url('/plan/plans/${id}/publish'));
}
/**
@ -462,9 +462,9 @@ class PlanController extends AdminController
$planableTypeHygiene = (new PlanHygiene())->getMorphClass();
return [
$planableTypeLedger => '<span class="label label-primary">'.$this->planableTypeOptions()[$planableTypeLedger ].'</span>',
$planableTypePerformance => '<span class="label label-danger">'.$this->planableTypeOptions()[$planableTypePerformance ].'</span>',
$planableTypeHygiene => '<span class="label label-success">'.$this->planableTypeOptions()[$planableTypeHygiene ].'</span>',
$planableTypeLedger => '<span class="label label-primary">'.$this->planableTypeOptions()[$planableTypeLedger].'</span>',
$planableTypePerformance => '<span class="label label-danger">'.$this->planableTypeOptions()[$planableTypePerformance].'</span>',
$planableTypeHygiene => '<span class="label label-success">'.$this->planableTypeOptions()[$planableTypeHygiene].'</span>',
];
}
}

View File

@ -45,7 +45,7 @@ class SettingController extends AdminController
amis()->SwitchControl('oss_config.use_ssl', '开启SSL')->value(false)->visibleOn('${upload_disk == "oss"}'),
]),
Tab::make()->title('打卡设置')->body([
amis()->NumberControl()->min(0)->name('sign.distance')->label('允许打卡的距离(米)')
amis()->NumberControl()->min(0)->name('sign.distance')->label('允许打卡的距离(米)'),
]),
])
);

View File

@ -83,6 +83,7 @@ class EmployeeController extends AdminController
protected function exportMap($row)
{
$jobs = data_get($row, 'jobs', []);
return [
__('employee.store_id') => data_get($row, 'store.title'),
__('admin.username') => data_get($row, 'admin_user.username'),

View File

@ -153,8 +153,8 @@ class StoreController extends AdminController
__('store.category_id') => data_get($row, 'category.name'),
__('store.business_id') => data_get($row, 'business.name'),
__('store.level_id') => data_get($row, 'level.name'),
__('store.profit_ratio') => data_get($row, 'profit_ratio') . '%',
__('store.region') => data_get($row, 'region.province') . '-' . data_get($row, 'region.city'),
__('store.profit_ratio') => data_get($row, 'profit_ratio').'%',
__('store.region') => data_get($row, 'region.province').'-'.data_get($row, 'region.city'),
__('store.business_status') => data_get(BusinessStatus::options(), data_get($row, 'business_status'), ''),
__('store.address') => data_get($row, 'address'),
__('store.created_at') => data_get($row, 'created_at'),

View File

@ -4,7 +4,6 @@ namespace App\Admin\Controllers\Store;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\StoreProfitRatioLogService;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Page;
/**

View File

@ -76,7 +76,7 @@ class AdminUserController extends AdminController
public function form(): Form
{
return $this->baseForm()->body([
amis()->ImageControl('avatar', __('admin.admin_user.avatar'))->receiver(admin_url('upload_image') . '?full-url=1'),
amis()->ImageControl('avatar', __('admin.admin_user.avatar'))->receiver(admin_url('upload_image').'?full-url=1'),
amis()->TextControl('name', __('admin.admin_user.name'))->required(),
amis()->TextControl('username', __('admin.username'))->required(),
amis()->TextControl('password', __('admin.password'))->type('input-password')->required()->validations(['minLength' => 6])->hiddenOn('${id > 0}'),

View File

@ -4,7 +4,8 @@ namespace App\Admin\Controllers\System;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\{WorkFlowService};
use App\Enums\{CheckType, CheckStatus};
use App\Enums\CheckStatus;
use App\Enums\CheckType;
use App\Models\Employee;
use App\Models\Keyword;
use App\Models\WorkflowCheck;
@ -242,7 +243,7 @@ class WorkflowController extends AdminController
return $this->response()->fail('当前登录账户未关联员工');
}
$log = WorkflowLog::find($request->input('id'));
if (!$log) {
if (! $log) {
return $this->response()->fail('审核已取消');
}
try {
@ -271,7 +272,7 @@ class WorkflowController extends AdminController
return $this->response()->fail('当前登录账户未关联员工');
}
$log = WorkflowLog::find($request->input('id'));
if (!$log) {
if (! $log) {
return $this->response()->fail('审核已取消');
}
try {
@ -295,7 +296,7 @@ class WorkflowController extends AdminController
// 判断当前用户是否有权限审核
$user = Employee::with(['jobs'])->where('admin_user_id', Admin::user()->id)->first();
if ($user) {
foreach($list as &$item) {
foreach ($list as &$item) {
$item->checkable = $item->check_status == CheckStatus::Processing && $this->service->authCheck($user, $item);
}
}

View File

@ -2,13 +2,13 @@
namespace App\Admin\Controllers\Train;
use App\Admin\Components;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\Train\BookService;
use App\Enums\BookType;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page;
use App\Enums\BookType;
use App\Admin\Components;
/**
* 课件管理
@ -65,18 +65,18 @@ class BookController extends AdminController
->valueField('key')
->required(),
amisMake()->TextControl()->name('title')->label(__('train_book.title'))->required(),
amisMake()->ImageControl()->name('cover_image')->label(__('train_book.cover_image'))->receiver(admin_url('upload_image') . '?full-url=1'),
amisMake()->ImageControl()->name('cover_image')->label(__('train_book.cover_image'))->receiver(admin_url('upload_image').'?full-url=1'),
amisMake()->TextControl()->name('description')->label(__('train_book.description')),
amisMake()->RadiosControl()->options(BookType::options())->name('type')->label(__('train_book.type')),
Components::make()->fuEditorControl('content', __('train_book.content'))->visibleOn('${type == '.BookType::Text->value.'}'),
amisMake()->FileControl()->name('video')->label(__('train_book.video'))
->receiver(admin_url('upload_file') . '?full-url=1')
->receiver(admin_url('upload_file').'?full-url=1')
->startChunkApi(admin_url('start_chunk_upload_file'))
->chunkApi(admin_url('save_chunk_upload_file'))
->finishChunkApi(admin_url('finish_chunk_upload_file'))
->visibleOn('${type == '.BookType::Video->value.'}'),
amisMake()->FileControl()->name('files')->label(__('train_book.files'))
->receiver(admin_url('upload_file') . '?full-url=1')
->receiver(admin_url('upload_file').'?full-url=1')
->multiple()
->joinValues(false)
->startChunkApi(admin_url('start_chunk_upload_file'))
@ -104,6 +104,7 @@ class BookController extends AdminController
['label' => __('train_book.video'), 'content' => amisMake()->Video()->src('${video}'), 'span' => 3, 'visibleOn' => '${type == '.BookType::Video->value.'}'],
['label' => __('train_book.files'), 'content' => $list, 'span' => 3, 'visibleOn' => '${type == '.BookType::File->value.'}'],
];
return $this->baseDetail()->title('')->body(amisMake()->Property()->items($items));
}
}

View File

@ -4,13 +4,15 @@ namespace App\Admin\Controllers\Train;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\Train\ExaminationService;
use App\Enums\ExamStatus;
use App\Enums\QuestionCate;
use App\Models\Train\Examination;
use App\Models\Train\Question;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page;
use App\Enums\{ExamStatus, QuestionCate};
use App\Models\Train\{Question, Examination};
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* 考试管理
@ -56,7 +58,7 @@ class ExaminationController extends AdminController
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
amisMake()->DialogAction()->dialog(
amisMake()->Dialog()->title('选择参考员工')->size('lg')->body(
amisMake()->Form()->api('post:' . admin_url('train/examinations/${id}/publish'))->body([
amisMake()->Form()->api('post:'.admin_url('train/examinations/${id}/publish'))->body([
amisMake()->TransferControl()
->name('employee_id')
->source(admin_url('api/employees?enable=1'))
@ -73,7 +75,7 @@ class ExaminationController extends AdminController
->level('link')
->visible(Admin::user()->can('admin.train.examinations.publish'))
->visibleOn('${exam_status == '.ExamStatus::None->value.'}'),
amisMake()->AjaxAction()->api('post:' . admin_url('train/examinations/${id}/cancel'))
amisMake()->AjaxAction()->api('post:'.admin_url('train/examinations/${id}/cancel'))
->label(__('train_examination.cancel'))
->level('link')
->confirmText('删除该考试下所有试卷记录, 是否确定?')
@ -95,7 +97,7 @@ class ExaminationController extends AdminController
->valueField('id')
->multiple(true)
->autoFill([
'questions' => '${items}'
'questions' => '${items}',
])
->value('${questions}')
->size('lg')
@ -151,25 +153,28 @@ class ExaminationController extends AdminController
]),
amisMake()->TableColumn()->name('score')->label(__('train_examination.score')),
]);
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
}
public function publish($id, Request $request)
{
$request->validate([
'employee_id' => 'required'
'employee_id' => 'required',
]);
$info = Examination::findOrFail($id);
try {
DB::beginTransaction();
if (!$this->service->publish($info, $request->input('employee_id'))) {
if (! $this->service->publish($info, $request->input('employee_id'))) {
return $this->response()->fail($this->service->getError());
}
DB::commit();
return $this->response()->success();
} catch (\Exception $e) {
DB::rollBack();
return $this->response()->fail($e->getMessage());
}
@ -182,13 +187,15 @@ class ExaminationController extends AdminController
try {
DB::beginTransaction();
if (!$this->service->cancel($info)) {
if (! $this->service->cancel($info)) {
return $this->response()->fail($this->service->getError());
}
DB::commit();
return $this->response()->success();
} catch (\Exception $e) {
DB::rollBack();
return $this->response()->fail($e->getMessage());
}
}

View File

@ -4,10 +4,9 @@ namespace App\Admin\Controllers\Train;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\Train\PaperService;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\QuestionCate;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page;
use App\Enums\QuestionCate;
/**
* 成绩管理
@ -64,6 +63,7 @@ class PaperController extends AdminController
amisMake()->TableColumn()->name('score')->label(__('train_question.score')),
amisMake()->TableColumn()->name('user_score')->label(__('train_question.user_score')),
]);
return $this->baseDetail()->title('')->body([$detail, amisMake()->Divider(), $question]);
}
}

View File

@ -4,10 +4,10 @@ namespace App\Admin\Controllers\Train;
use App\Admin\Controllers\AdminController;
use App\Admin\Services\Train\QuestionService;
use App\Enums\QuestionCate;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Renderers\Form;
use Slowlyo\OwlAdmin\Renderers\Page;
use App\Enums\QuestionCate;
/**
* 题库管理
@ -84,6 +84,7 @@ class QuestionController extends AdminController
]), 'span' => 3],
]));
}
public function shareList()
{
return $this->response()->success($this->service->list());

View File

@ -19,8 +19,8 @@ class AgreementFilter extends ModelFilter
'invitor_search' => 'search',
],
'workflow' => [
'check_status' => 'check_status'
]
'check_status' => 'check_status',
],
];
public function employeeId($key)

View File

@ -12,7 +12,7 @@ class EmployeeFilter extends ModelFilter
'province_code' => 'province_code',
'province_code' => 'province_code',
'city_code' => 'city_code',
]
],
];
protected $drop_id = false;

View File

@ -22,8 +22,8 @@ class EmployeePromotionFilter extends ModelFilter
'invitor_search' => 'search',
],
'workflow' => [
'check_status' => 'check_status'
]
'check_status' => 'check_status',
],
];
public function employeeId($key)

View File

@ -18,8 +18,8 @@ class OvertimeApplyFilter extends ModelFilter
'employee_search' => 'search',
],
'workflow' => [
'check_status' => 'check_status'
]
'check_status' => 'check_status',
],
];
public function employeeId($key)

View File

@ -2,9 +2,9 @@
namespace App\Admin\Filters;
use App\Models\Keyword;
use EloquentFilter\ModelFilter;
use Illuminate\Support\Arr;
use App\Models\Keyword;
class StoreFilter extends ModelFilter
{

View File

@ -10,6 +10,7 @@ class TrainExaminationFilter extends ModelFilter
public function search($key)
{
$condition = '%'.$key.'%';
return $this->where('name', 'like', $condition);
}

View File

@ -2,7 +2,6 @@
namespace App\Admin\Filters;
use Carbon\Carbon;
use EloquentFilter\ModelFilter;
class TrianPaperFilter extends ModelFilter

View File

@ -10,6 +10,7 @@ class TrianQuestionFilter extends ModelFilter
public function search($key)
{
$condition = '%'.$key.'%';
return $this->where('title', 'like', $condition);
}

View File

@ -21,7 +21,7 @@ class CheckPermission
'/finish_chunk_upload_file',
'/upload_file',
'/upload_image',
'/upload_rich'
'/upload_rich',
];
/**

View File

@ -3,13 +3,12 @@
namespace App\Admin\Services;
use App\Admin\Filters\AgreementFilter;
use App\Models\{Agreement, WorkflowCheck, Employee};
use Illuminate\Support\Facades\{Validator, Storage};
use Illuminate\Support\Str;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
use App\Models\Agreement;
use App\Models\Employee;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
use Slowlyo\OwlAdmin\Models\AdminUser;
use App\Exceptions\RuntimeException;
class AgreementService extends BaseService
{
@ -32,7 +31,7 @@ class AgreementService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -47,10 +46,10 @@ class AgreementService extends BaseService
if ($user->can('admin.agreement.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.agreement.update') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.agreement.update') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'edit');
}
if ($user->can('admin.agreement.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.agreement.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'delete');
}
if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) {
@ -85,6 +84,7 @@ class AgreementService extends BaseService
}
$data['images'] = $images;
}
return $data;
}
@ -106,7 +106,7 @@ class AgreementService extends BaseService
public function update($primaryKey, $data): bool
{
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
return $this->setError('审核中, 无法修改');
}
$data = $this->resloveData($data, $model);
@ -119,6 +119,7 @@ class AgreementService extends BaseService
$model->update($data);
$this->currentModel = $model;
return true;
}
@ -128,6 +129,7 @@ class AgreementService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -6,12 +6,9 @@ use App\Admin\Filters\AppVersionFilter;
use App\Enums\AppOs;
use App\Enums\AppUpdateStrategy;
use App\Models\AppVersion;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Slowlyo\OwlAdmin\Admin;
class AppVersionService extends BaseService
{
@ -178,6 +175,7 @@ class AppVersionService extends BaseService
'apk_url' => $apkUrl,
'wgt_url' => $wgtUrl,
]));
return true;
}
}

View File

@ -2,8 +2,8 @@
namespace App\Admin\Services;
use Slowlyo\OwlAdmin\Services\AdminService;
use Illuminate\Database\Eloquent\Model;
use Slowlyo\OwlAdmin\Services\AdminService;
/**
* @method Region getModel()
@ -104,6 +104,7 @@ class BaseService extends AdminService
}
$model->update($data);
$this->currentModel = $model;
return true;
}

View File

@ -3,17 +3,14 @@
namespace App\Admin\Services;
use App\Admin\Filters\EmployeePromotionFilter;
use App\Admin\WorkflowService;
use App\Enums\PromotionStatus;
use App\Models\Employee;
use App\Models\EmployeePromotion;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Arr;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
use Slowlyo\OwlAdmin\Models\AdminUser;
use App\Exceptions\RuntimeException;
class EmployeePromotionService extends BaseService
{
@ -36,7 +33,7 @@ class EmployeePromotionService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -51,10 +48,10 @@ class EmployeePromotionService extends BaseService
if ($user->can('admin.hr.promotion.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.hr.promotion.update') && !in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
if ($user->can('admin.hr.promotion.update') && ! in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
array_push($actions, 'edit');
}
if ($user->can('admin.hr.promotion.delete') && !in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
if ($user->can('admin.hr.promotion.delete') && ! in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Success])) {
array_push($actions, 'delete');
}
if (in_array($model->promotion_status, [PromotionStatus::Processing])) {
@ -154,7 +151,7 @@ class EmployeePromotionService extends BaseService
public function update($primaryKey, $data): bool
{
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
return $this->setError('审核中, 无法修改');
}
$data = $this->resloveData($data, $model);
@ -167,6 +164,7 @@ class EmployeePromotionService extends BaseService
$model->update($data);
$this->currentModel = $model;
return true;
}
@ -176,6 +174,7 @@ class EmployeePromotionService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -3,15 +3,17 @@
namespace App\Admin\Services;
use App\Admin\Filters\EmployeeFilter;
use App\Models\{Employee, EmployeeSignLog, HolidayApply, OvertimeApply, OfficalBusiness};
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use App\Admin\Services\System\AdminUserService;
use App\Enums\EmployeeStatus;
use App\Models\Employee;
use App\Models\EmployeeSignLog;
use App\Models\HolidayApply;
use App\Models\OfficalBusiness;
use App\Models\OvertimeApply;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Models\AdminUser;
use App\Admin\Services\System\AdminUserService;
use App\Enums\EmployeeStatus;
class EmployeeService extends BaseService
{
@ -64,7 +66,7 @@ class EmployeeService extends BaseService
// 修改管理员
$adminUserService = AdminUserService::make();
if (!$adminUserService->update($model->admin_user_id, Arr::only($data, ['password', 'confirm_password', 'name', 'avatar']))) {
if (! $adminUserService->update($model->admin_user_id, Arr::only($data, ['password', 'confirm_password', 'name', 'avatar']))) {
return $this->setError($adminUserService->getError());
}

View File

@ -3,13 +3,13 @@
namespace App\Admin\Services;
use App\Admin\Filters\EmployeeSignRepairFilter;
use App\Models\{EmployeeSignRepair, Employee, WorkflowCheck, EmployeeSign, EmployeeSignLog};
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
use App\Models\AdminUser;
use App\Exceptions\RuntimeException;
use App\Models\Employee;
use App\Models\EmployeeSignLog;
use App\Models\EmployeeSignRepair;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
class EmployeeSignRepairService extends BaseService
{
@ -32,7 +32,7 @@ class EmployeeSignRepairService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -47,7 +47,7 @@ class EmployeeSignRepairService extends BaseService
if ($user->can('admin.hr.repairs.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.hr.repairs.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.hr.repairs.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'delete');
}
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
@ -92,12 +92,12 @@ class EmployeeSignRepairService extends BaseService
if ($validator->fails()) {
return $validator->errors()->first();
}
if (!$model) {
if (! $model) {
// 已经打卡, 不能申请
if (EmployeeSignLog::filter([
'date' => $data['date'],
'employee_id' => $data['employee_id'],
'sign_time' => $data['sign_time']
'sign_time' => $data['sign_time'],
])->exists()) {
return '已经补过卡了';
}
@ -120,6 +120,7 @@ class EmployeeSignRepairService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -3,8 +3,14 @@
namespace App\Admin\Services;
use App\Admin\Filters\EmployeeSignFilter;
use App\Enums\{SignStatus, SignTime, SignType};
use App\Models\{Employee, EmployeeRest, EmployeeSign, EmployeeSignLog, EmployeeSignRepair};
use App\Enums\SignStatus;
use App\Enums\SignTime;
use App\Enums\SignType;
use App\Models\Employee;
use App\Models\EmployeeRest;
use App\Models\EmployeeSign;
use App\Models\EmployeeSignLog;
use App\Models\EmployeeSignRepair;
use Carbon\Carbon;
class EmployeeSignService extends BaseService
@ -31,7 +37,7 @@ class EmployeeSignService extends BaseService
/**
* 整理昨天的打卡流水, 生成对应的打卡记录
*/
public function signResult(Carbon $date = null)
public function signResult(?Carbon $date = null)
{
$date = $date ?: now()->subDay();
$start = $date->copy()->startOfDay();
@ -96,7 +102,7 @@ class EmployeeSignService extends BaseService
* @param SignTime $time 上班/下班 打卡
* @param mixed $date 打卡时间
* @param array $options {type: 正常/外勤 打卡, remarks: 备注, position: 位置}
* @return boolean
* @return bool
*/
public function signDay(Employee $user, SignTime $time, $date = '', array $options = [])
{
@ -123,7 +129,7 @@ class EmployeeSignService extends BaseService
$sign->sign_type = $log->sign_type;
if ($time == SignTime::Morning) {
$sign->first_time = $log->time;
} else if ($time == SignTime::Afternoon) {
} elseif ($time == SignTime::Afternoon) {
$sign->last_time = $log->time;
}
$sign->sign_status = SignStatus::Lose;
@ -143,6 +149,7 @@ class EmployeeSignService extends BaseService
public function hasRest(Employee $user, $date = '')
{
$date = $date ?: now();
return EmployeeRest::where('employee_id', $user->id)->where('date', $date)->exists();
}
@ -165,8 +172,8 @@ class EmployeeSignService extends BaseService
$dlat = $lat2 - $lat1;
// Calculate the Haversine formula
$a = pow(sin($dlat/2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon/2), 2);
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
$a = pow(sin($dlat / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($dlon / 2), 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$distance = $R * $c;
return floor($distance * 1000);

View File

@ -3,11 +3,12 @@
namespace App\Admin\Services;
use App\Admin\Filters\HolidayApplyFilter;
use App\Models\{HolidayApply, Employee};
use App\Enums\CheckStatus;
use App\Models\Employee;
use App\Models\HolidayApply;
use Carbon\Carbon;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
class HolidayApplyService extends BaseService
{
@ -30,7 +31,7 @@ class HolidayApplyService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -45,7 +46,7 @@ class HolidayApplyService extends BaseService
if ($user->can('admin.hr.holiday.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.hr.holiday.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.hr.holiday.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'delete');
}
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
@ -96,7 +97,7 @@ class HolidayApplyService extends BaseService
public function update($primaryKey, $data): bool
{
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
return $this->setError('审核中, 无法修改');
}
$data = $this->resloveData($data, $model);
@ -109,6 +110,7 @@ class HolidayApplyService extends BaseService
$model->update($data);
$this->currentModel = $model;
return true;
}
@ -118,6 +120,7 @@ class HolidayApplyService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -3,11 +3,12 @@
namespace App\Admin\Services;
use App\Admin\Filters\OfficalBusinessFilter;
use App\Models\{Employee, OfficalBusiness};
use App\Enums\CheckStatus;
use App\Models\Employee;
use App\Models\OfficalBusiness;
use Carbon\Carbon;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
class OfficalBusinessService extends BaseService
{
@ -30,7 +31,7 @@ class OfficalBusinessService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -45,7 +46,7 @@ class OfficalBusinessService extends BaseService
if ($user->can('admin.hr.business.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.hr.business.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.hr.business.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'delete');
}
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
@ -96,7 +97,7 @@ class OfficalBusinessService extends BaseService
public function update($primaryKey, $data): bool
{
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
return $this->setError('审核中, 无法修改');
}
$data = $this->resloveData($data, $model);
@ -109,6 +110,7 @@ class OfficalBusinessService extends BaseService
$model->update($data);
$this->currentModel = $model;
return true;
}
@ -118,6 +120,7 @@ class OfficalBusinessService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -3,11 +3,12 @@
namespace App\Admin\Services;
use App\Admin\Filters\OvertimeApplyFilter;
use App\Models\{Employee, OvertimeApply};
use App\Enums\CheckStatus;
use App\Models\Employee;
use App\Models\OvertimeApply;
use Carbon\Carbon;
use Illuminate\Support\Facades\Validator;
use Slowlyo\OwlAdmin\Admin;
use App\Enums\CheckStatus;
class OvertimeApplyService extends BaseService
{
@ -30,7 +31,7 @@ class OvertimeApplyService extends BaseService
$total = $list->total();
}
$user = Admin::user();
foreach($items as &$item) {
foreach ($items as &$item) {
$item->row_actions = $this->rowActions($user, $item);
}
@ -45,7 +46,7 @@ class OvertimeApplyService extends BaseService
if ($user->can('admin.hr.overtime.view')) {
array_push($actions, 'view');
}
if ($user->can('admin.hr.overtime.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
if ($user->can('admin.hr.overtime.delete') && ! in_array($model->workflow->check_status, [CheckStatus::Processing, CheckStatus::Success])) {
array_push($actions, 'delete');
}
if (in_array($model->workflow->check_status, [CheckStatus::None, CheckStatus::Cancel, CheckStatus::Fail])) {
@ -108,7 +109,7 @@ class OvertimeApplyService extends BaseService
public function update($primaryKey, $data): bool
{
$model = $this->query()->whereKey($primaryKey)->firstOrFail();
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
return $this->setError('审核中, 无法修改');
}
$data = $this->resloveData($data, $model);
@ -128,6 +129,7 @@ class OvertimeApplyService extends BaseService
foreach ($list as $item) {
$item->delete();
}
return true;
}
}

View File

@ -220,6 +220,7 @@ class PlanService extends BaseService
/** @var \Illuminate\Support\Collection */
$ids = Keyword::where('path', 'like', "%-{$parent->id}-%")->pluck('key');
}
return $ids->push($id);
}, $plan->planable->store_category_id);
@ -280,6 +281,7 @@ class PlanService extends BaseService
);
}
}
return $plan;
}

View File

@ -45,7 +45,7 @@ class StoreService extends BaseService
StoreProfitRatioLog::create([
'store_id' => $model->id,
'employee_id' => $employee->id,
'before' => $beforeProfitRatio ,
'before' => $beforeProfitRatio,
'after' => $afterProfitRatio,
]);
}
@ -90,7 +90,7 @@ class StoreService extends BaseService
StoreProfitRatioLog::create([
'store_id' => $model->id,
'employee_id' => $employee->id,
'before' => $beforeProfitRatio ,
'before' => $beforeProfitRatio,
'after' => $afterProfitRatio,
]);
}

View File

@ -3,10 +3,11 @@
namespace App\Admin\Services\Train;
use App\Admin\Filters\TrianBookFilter;
use App\Models\Train\Book;
use App\Admin\Services\BaseService;
use App\Models\Train\Book;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\{Validator, Storage};
class BookService extends BaseService
{
@ -30,12 +31,13 @@ class BookService extends BaseService
'files' => ['nullable', 'array'],
];
$updateRules = [
'files' => ['nullable','array'],
'files' => ['nullable', 'array'],
];
$validator = Validator::make($data, $model ? $updateRules : $createRules);
if ($validator->fails()) {
return $validator->errors()->first();
}
return true;
}
}

View File

@ -3,13 +3,12 @@
namespace App\Admin\Services\Train;
use App\Admin\Filters\TrainExaminationFilter;
use App\Models\Train\{Examination, Question};
use App\Admin\Services\BaseService;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\{Validator, Storage};
use App\Enums\ExamStatus;
use App\Enums\MessageType;
use App\Models\Employee;
use App\Models\Train\Examination;
use App\Models\Train\Question;
use App\Services\MessageService;
class ExaminationService extends BaseService
@ -30,7 +29,7 @@ class ExaminationService extends BaseService
$model->min_mark = $model->papers->whereNotNull('finished_at')->min('mark');
$model->max_mark = $model->papers->whereNotNull('finished_at')->max('mark');
$model->avg_mark = floor($model->papers->whereNotNull('finished_at')->avg('mark') * 100) / 100;
$model->total_finished = $model->papers->whereNotNull('finished_at')->count() . '/'.$model->papers->count();
$model->total_finished = $model->papers->whereNotNull('finished_at')->count().'/'.$model->papers->count();
return $model;
}
@ -59,13 +58,14 @@ class ExaminationService extends BaseService
array_push($questions, $item);
$totalQuestions++;
$totalScore+=$item['score'];
$totalScore += $item['score'];
}
}
$data['questions'] = $questions;
$data['total_questions'] = $totalQuestions;
$data['total_score'] = $totalScore;
}
return $data;
}
@ -76,9 +76,10 @@ class ExaminationService extends BaseService
}
$questions = [];
foreach($examination->questions as $question) {
foreach ($examination->questions as $question) {
$question['options'] = array_map(function ($option) {
$option['selected'] = false;
return $option;
}, $question['options']);
array_push($questions, $question);

View File

@ -3,10 +3,8 @@
namespace App\Admin\Services\Train;
use App\Admin\Filters\TrianPaperFilter;
use App\Models\Train\Paper;
use App\Admin\Services\BaseService;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\{Validator, Storage};
use App\Models\Train\Paper;
class PaperService extends BaseService
{
@ -19,9 +17,8 @@ class PaperService extends BaseService
/**
* 答题
*
* @param Paper $paper
* @param array $answers [[0, 1], [1], [2, 3]]
* @return boolean
* @return bool
*/
public function answer(Paper $paper, array $answers)
{
@ -36,7 +33,7 @@ class PaperService extends BaseService
$score = $item['score'];
foreach ($item['options'] as $subIndex => $option) {
$option['selected'] = in_array($subIndex, $item['user_answer']);
if ((!$option['is_true'] && $option['selected']) || ($option['is_true'] && !$option['selected'])) {
if ((! $option['is_true'] && $option['selected']) || ($option['is_true'] && ! $option['selected'])) {
$score = 0;
}
array_push($options, $option);
@ -52,5 +49,4 @@ class PaperService extends BaseService
return true;
}
}

View File

@ -3,10 +3,8 @@
namespace App\Admin\Services\Train;
use App\Admin\Filters\TrianQuestionFilter;
use App\Models\Train\Question;
use App\Admin\Services\BaseService;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\{Validator, Storage};
use App\Models\Train\Question;
class QuestionService extends BaseService
{
@ -20,12 +18,13 @@ class QuestionService extends BaseService
{
if (isset($data['options']) && $data['options']) {
$options = [];
foreach($data['options'] as $key => $item) {
foreach ($data['options'] as $key => $item) {
$item['is_true'] = data_get($item, 'is_true', false);
array_push($options, $item);
}
$data['options'] = $options;
}
return $data;
}
}

View File

@ -2,7 +2,8 @@
namespace App\Admin\Services;
use App\Enums\{CheckStatus, CheckType};
use App\Enums\CheckStatus;
use App\Enums\CheckType;
use App\Events\WorkflowCheckFailed;
use App\Events\WorkflowCheckNext;
use App\Events\WorkflowCheckSuccess;
@ -30,7 +31,6 @@ class WorkFlowService extends BaseService
*
* @param WorkflowCheck $check 待审核记录
* @param Employee $user 申请人
*
* @return bool true: 成功, false: 失败, $this->getError(): 错误消息
*/
public function apply(WorkflowCheck $check, Employee $user)
@ -225,8 +225,8 @@ class WorkFlowService extends BaseService
}
$checkValue = [$user->id];
if ($user->jobs && $user->jobs->count() > 0) {
foreach($user->jobs as $item) {
array_push($checkValue, $user->store_id . '-' . $item->key);
foreach ($user->jobs as $item) {
array_push($checkValue, $user->store_id.'-'.$item->key);
}
}
@ -241,8 +241,8 @@ class WorkFlowService extends BaseService
$data['config'] = null;
break;
}
if (!isset($item['value'])) {
$item['value'] = match($item['type']) {
if (! isset($item['value'])) {
$item['value'] = match ($item['type']) {
CheckType::Job->value => $item['job'],
CheckType::User->value => $item['user'],
};

View File

@ -3,9 +3,9 @@
namespace App\Console\Commands;
use App\Admin\Services\EmployeeSignService;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class EmployeeSign extends Command
{

View File

@ -49,7 +49,7 @@ class TaskLedgerGenerateCommand extends Command
}
/** @var \App\Models\PlanLedger */
$planable = DB::transaction(function () use ($datetime, $stores) {
$planable = DB::transaction(function () use ($datetime) {
/** @var \App\Models\PlanLedger */
$planable = PlanLedger::firstOrNew([
'date' => $datetime->format('Y-m-d'),

View File

@ -46,8 +46,9 @@ enum CheckStatus: int
self::Success->value => '已通过',
self::Fail->value => '未通过',
// self::Cancel->value => '已取消',
]
],
];
return data_get($maps, $index);
}

View File

@ -16,5 +16,6 @@ class WorkflowCheckFailed implements ShouldDispatchAfterCommit
*/
public function __construct(
public WorkflowCheck $workflowCheck
) {}
) {
}
}

View File

@ -16,5 +16,6 @@ class WorkflowCheckNext implements ShouldDispatchAfterCommit
*/
public function __construct(
public WorkflowLog $workflowLog,
) {}
) {
}
}

View File

@ -16,5 +16,6 @@ class WorkflowCheckSuccess implements ShouldDispatchAfterCommit
*/
public function __construct(
public WorkflowCheck $workflowCheck
) {}
) {
}
}

View File

@ -5,13 +5,13 @@ namespace App\Exceptions;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\{Request, Response};
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Validation\ValidationException;
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
use Slowlyo\OwlAdmin\Exceptions\AdminException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
class Handler extends ExceptionHandler
{
@ -60,6 +60,7 @@ class Handler extends ExceptionHandler
foreach ($e->getExceptions() as $exception) {
$this->report($exception);
}
return false;
});
}

View File

@ -29,6 +29,7 @@ class StorePerformanceController extends Controller
/**
* 当月的业绩指标任务
*
* @var \App\Models\TaskPerformance
*/
$taskPerformance = TaskPerformance::where('store_id', $user->store_id)

View File

@ -2,7 +2,8 @@
namespace App\Http\Controllers\Api;
use App\Admin\Services\{AgreementService, WorkFlowService};
use App\Admin\Services\AgreementService;
use App\Admin\Services\WorkFlowService;
use App\Exceptions\RuntimeException;
use App\Http\Resources\AgreementResource;
use App\Models\Agreement;
@ -43,16 +44,17 @@ class AgreementController extends Controller
try {
DB::beginTransaction();
if (!$service->store($data)) {
if (! $service->store($data)) {
throw new RuntimeException($result);
}
$model = $service->getCurrentModel();
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -67,15 +69,16 @@ class AgreementController extends Controller
try {
DB::beginTransaction();
if (!$service->update($id, $request->all())) {
if (! $service->update($id, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -90,11 +93,12 @@ class AgreementController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();

View File

@ -3,17 +3,17 @@
namespace App\Http\Controllers\Api\Auth;
use App\Admin\Services\EmployeeService;
use App\Enums\{UserRole, BusinessStatus};
use App\Enums\BusinessStatus;
use App\Enums\UserRole;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\KeywordResource;
use App\Http\Resources\StoreResource;
use App\Models\Message;
use App\Models\{Employee, Store, AdminUser};
use Illuminate\Http\{Request, Response};
use App\Models\Store;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;
/**
* 个人中心
@ -41,6 +41,7 @@ class UserController extends Controller
'role' => $user->userRole(),
];
}
// 修改账户信息
public function update(Request $request)
{
@ -49,7 +50,7 @@ class UserController extends Controller
DB::beginTransaction();
$service = EmployeeService::make();
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone']);
if (!$service->update($user->id, $data)) {
if (! $service->update($user->id, $data)) {
throw new RuntimeException($service->getError());
}
DB::commit();
@ -57,6 +58,7 @@ class UserController extends Controller
DB::rollback();
throw new RuntimeException($e->getMessage());
}
return response('', Response::HTTP_OK);
}
@ -69,7 +71,7 @@ class UserController extends Controller
$query = Store::filter($request->all())->where('business_status', BusinessStatus::Open);
if (in_array(UserRole::Admin, $role)) {
$list = $query->get();
} else if (in_array(UserRole::StoreUser, $role) || in_array(UserRole::Store, $role)) {
} elseif (in_array(UserRole::StoreUser, $role) || in_array(UserRole::Store, $role)) {
$list = [$query->findOrFail($user->store_id)];
}

View File

@ -2,15 +2,16 @@
namespace App\Http\Controllers\Api\Hr;
use App\Http\Controllers\Api\Controller;
use App\Models\{Employee, Store, AdminUser};
use Illuminate\Http\{Request, Response};
use App\Enums\UserRole;
use App\Http\Resources\EmployeeResource;
use App\Admin\Services\EmployeeService;
use App\Exceptions\RuntimeException;
use Illuminate\Support\Facades\DB;
use App\Enums\EmployeeStatus;
use App\Enums\UserRole;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\EmployeeResource;
use App\Models\Employee;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
/**
* 员工管理
@ -24,7 +25,7 @@ class EmployeeController extends Controller
$filter = $request->all();
$query = Employee::with(['jobs', 'store', 'adminUser'])->filter($filter)->enable();
if (!in_array(UserRole::Admin, $role)) {
if (! in_array(UserRole::Admin, $role)) {
$query->whereIn('store_id', [$user->store_id]);
}
$list = $query->orderBy('id', 'desc')->paginate($request->input('per_page'));
@ -45,7 +46,7 @@ class EmployeeController extends Controller
DB::beginTransaction();
$service = EmployeeService::make();
$data = $request->all();
if (!$service->store($data)) {
if (! $service->store($data)) {
throw new RuntimeException($service->getError());
}
DB::commit();
@ -53,6 +54,7 @@ class EmployeeController extends Controller
DB::rollback();
throw new RuntimeException($e->getMessage());
}
return response('', Response::HTTP_CREATED);
}
@ -62,7 +64,7 @@ class EmployeeController extends Controller
DB::beginTransaction();
$service = EmployeeService::make();
$data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone', 'store_id']);
if (!$service->update($id, $data)) {
if (! $service->update($id, $data)) {
throw new RuntimeException($service->getError());
}
DB::commit();
@ -70,6 +72,7 @@ class EmployeeController extends Controller
DB::rollback();
throw new RuntimeException($e->getMessage());
}
return response('', Response::HTTP_OK);
}
@ -78,7 +81,7 @@ class EmployeeController extends Controller
try {
DB::beginTransaction();
$service = EmployeeService::make();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
@ -86,6 +89,7 @@ class EmployeeController extends Controller
DB::rollback();
throw new RuntimeException($e->getMessage());
}
return response('', Response::HTTP_OK);
}
@ -98,7 +102,7 @@ class EmployeeController extends Controller
throw new RuntimeException('未入职');
}
$service = EmployeeService::make();
if (!$service->leave($info)) {
if (! $service->leave($info)) {
throw new RuntimeException($service->getError());
}
DB::commit();
@ -106,6 +110,7 @@ class EmployeeController extends Controller
DB::rollback();
throw new RuntimeException($e->getMessage());
}
return response('', Response::HTTP_OK);
}
}

View File

@ -2,7 +2,8 @@
namespace App\Http\Controllers\Api\Hr;
use App\Admin\Services\{HolidayApplyService, WorkFlowService};
use App\Admin\Services\HolidayApplyService;
use App\Admin\Services\WorkFlowService;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\HolidayApplyResource;
@ -52,11 +53,12 @@ class HolidayController extends Controller
}
$model = HolidayApply::create($data);
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -71,15 +73,16 @@ class HolidayController extends Controller
try {
DB::beginTransaction();
if (!$service->update($id, $request->all())) {
if (! $service->update($id, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -94,11 +97,12 @@ class HolidayController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,7 +2,8 @@
namespace App\Http\Controllers\Api\Hr;
use App\Admin\Services\{OfficalBusinessService, WorkFlowService};
use App\Admin\Services\OfficalBusinessService;
use App\Admin\Services\WorkFlowService;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\OfficalBusinessResource;
@ -44,16 +45,17 @@ class OfficalBusinessController extends Controller
try {
DB::beginTransaction();
if (!$service->store($data)) {
if (! $service->store($data)) {
throw new RuntimeException($service->getError());
}
$model = $service->getCurrentModel();
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -68,15 +70,16 @@ class OfficalBusinessController extends Controller
try {
DB::beginTransaction();
if (!$service->update($id, $request->all())) {
if (! $service->update($id, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -91,11 +94,12 @@ class OfficalBusinessController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,7 +2,8 @@
namespace App\Http\Controllers\Api\Hr;
use App\Admin\Services\{OvertimeApplyService, WorkFlowService};
use App\Admin\Services\OvertimeApplyService;
use App\Admin\Services\WorkFlowService;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\OvertimeApplyResource;
@ -59,16 +60,17 @@ class OvertimeController extends Controller
try {
DB::beginTransaction();
if (!$service->store($data)) {
if (! $service->store($data)) {
throw new RuntimeException($service->getError());
}
$model = $service->getCurrentModel();
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -98,15 +100,16 @@ class OvertimeController extends Controller
try {
DB::beginTransaction();
if (!$service->update($id, $request->all())) {
if (! $service->update($id, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -121,11 +124,12 @@ class OvertimeController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,7 +2,8 @@
namespace App\Http\Controllers\Api\Hr;
use App\Admin\Services\{EmployeePromotionService, WorkFlowService};
use App\Admin\Services\EmployeePromotionService;
use App\Admin\Services\WorkFlowService;
use App\Enums\PromotionStatus;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
@ -51,6 +52,7 @@ class PromotionController extends Controller
public function show($id)
{
$info = EmployeePromotion::with(['workflow', 'employee', 'invitor', 'job'])->findOrFail($id);
return EmployeePromotionResource::make($info);
}
@ -62,7 +64,7 @@ class PromotionController extends Controller
$user = $this->guard()->user();
$info = EmployeePromotion::where('employee_id', $user->id)->findOrFail($id);
if (!$service->apply($info, $request->all())) {
if (! $service->apply($info, $request->all())) {
throw new RuntimeException($service->getError());
}
@ -79,15 +81,16 @@ class PromotionController extends Controller
try {
DB::beginTransaction();
if (!$service->invitor($model, $request->all())) {
if (! $service->invitor($model, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $model->employee)) {
if (! $workflow->apply($model->workflow, $model->employee)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -104,17 +107,17 @@ class PromotionController extends Controller
DB::beginTransaction();
// 申请人完善资料
if ($info->promotion_status == PromotionStatus::Employee) {
if (!$service->apply($info, $request->only(['age', 'sex', 'education', 'first_work_time', 'work_years', 'work_years_in_company', 'comment_self', 'plans', 'reason']))) {
if (! $service->apply($info, $request->only(['age', 'sex', 'education', 'first_work_time', 'work_years', 'work_years_in_company', 'comment_self', 'plans', 'reason']))) {
throw new RuntimeException($service->getError());
}
}
// 推荐人填写
else if ($info->promotion_status == PromotionStatus::Invitor) {
if (!$service->invitor($info, $request->only(['reason']))) {
elseif ($info->promotion_status == PromotionStatus::Invitor) {
if (! $service->invitor($info, $request->only(['reason']))) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($info->workflow, $info->employee)) {
if (! $workflow->apply($info->workflow, $info->employee)) {
throw new RuntimeException($workflow->getError());
}
} else {
@ -122,6 +125,7 @@ class PromotionController extends Controller
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();
@ -136,11 +140,12 @@ class PromotionController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response()->noContent();
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,16 +2,19 @@
namespace App\Http\Controllers\Api\Hr;
use App\Http\Controllers\Api\Controller;
use App\Models\{EmployeeSign, EmployeeSignLog};
use Illuminate\Http\{Request, Response};
use App\Exceptions\RuntimeException;
use Illuminate\Support\Facades\DB;
use App\Admin\Services\EmployeeSignService;
use App\Enums\{SignTime, SignType, SignStatus};
use App\Enums\SignTime;
use App\Enums\SignType;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Models\EmployeeSign;
use App\Models\EmployeeSignLog;
use Carbon\Carbon;
use Slowlyo\OwlAdmin\Services\AdminSettingService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use Slowlyo\OwlAdmin\Services\AdminSettingService;
/**
* 考勤打卡
@ -27,7 +30,7 @@ class SignController extends Controller
$start = $time->copy()->startOfMonth();
$end = $time->copy()->endOfMonth();
do {
$info = $list->where(fn($item) => $item->date->format('Y-m-d') == $start->format('Y-m-d'))->first();
$info = $list->where(fn ($item) => $item->date->format('Y-m-d') == $start->format('Y-m-d'))->first();
array_push($data, [
'date' => $start->format('Y-m-d'),
'sign_status' => $info ? $info->sign_status : null,
@ -35,7 +38,7 @@ class SignController extends Controller
'last_time' => $info && $info->last_time ? $info->last_time->format('H:i') : '',
]);
$start->addDay();
} while(!$end->isSameDay($start));
} while (! $end->isSameDay($start));
return $data;
}
@ -44,7 +47,7 @@ class SignController extends Controller
{
$user = $this->guard()->user();
$store = $user->store;
if (!$store) {
if (! $store) {
throw new RuntimeException('没有绑定门店');
}
$date = now();
@ -102,7 +105,7 @@ class SignController extends Controller
$data = array_merge($data, [
'enable' => true,
'distance' => $distance,
'description' => '已进入考勤范围: ' . $store->title,
'description' => '已进入考勤范围: '.$store->title,
]);
}
}
@ -119,14 +122,14 @@ class SignController extends Controller
'position.lon' => ['required'],
'position.lat' => ['required'],
], [
'type.required' => __('employee_sign_log.sign_type') . '必填',
'time.required' => __('employee_sign_log.sign_time') . '必填',
'position.required' => __('employee_sign_log.position') . '必填',
'position.*.required' => __('employee_sign_log.position') . '必填',
'type.required' => __('employee_sign_log.sign_type').'必填',
'time.required' => __('employee_sign_log.sign_time').'必填',
'position.required' => __('employee_sign_log.position').'必填',
'position.*.required' => __('employee_sign_log.position').'必填',
]);
$user = $this->guard()->user();
$store = $user->store;
if (!$store) {
if (! $store) {
throw new RuntimeException('没有绑定门店');
}
$time = SignTime::from($request->input('time'));
@ -159,10 +162,11 @@ class SignController extends Controller
try {
DB::beginTransaction();
if (!$service->signDay($user, $time, now(), $request->only(['remarks', 'position', 'type']))) {
if (! $service->signDay($user, $time, now(), $request->only(['remarks', 'position', 'type']))) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,14 +2,16 @@
namespace App\Http\Controllers\Api\Hr;
use App\Admin\Services\{EmployeeSignRepairService, WorkFlowService};
use App\Admin\Services\EmployeeSignRepairService;
use App\Admin\Services\WorkFlowService;
use App\Enums\{CheckStatus};
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\{EmployeeSignRepairResource, WorkflowLogResource};
use App\Http\Resources\EmployeeSignRepairResource;
use App\Models\EmployeeSignRepair;
use App\Models\WorkflowCheck;
use Illuminate\Http\{Request, Response};
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
/**
@ -26,6 +28,7 @@ class SignRepairController extends Controller
->orderByDesc(WorkflowCheck::checkStatusSortBuilder(new EmployeeSignRepair()))
->orderBy('id', 'desc')
->paginate($request->input('per_page'));
return EmployeeSignRepairResource::collection($list);
}
@ -37,16 +40,17 @@ class SignRepairController extends Controller
try {
DB::beginTransaction();
if (!$service->store($data)) {
if (! $service->store($data)) {
throw new RuntimeException($service->getError());
}
$model = $service->getCurrentModel();
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();
@ -65,21 +69,22 @@ class SignRepairController extends Controller
{
$user = $this->guard()->user();
$model = EmployeeSignRepair::with(['workflow'])->where('employee_id', $user->id)->findOrFail($id);
if (!$model->canUpdate()) {
if (! $model->canUpdate()) {
throw new RuntimeException('审核中, 无法修改');
}
try {
DB::beginTransaction();
if (!$service->update($id, $request->all())) {
if (! $service->update($id, $request->all())) {
throw new RuntimeException($service->getError());
}
$workflow = WorkFlowService::make();
if (!$workflow->apply($model->workflow, $user)) {
if (! $workflow->apply($model->workflow, $user)) {
throw new RuntimeException($workflow->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();
@ -94,11 +99,12 @@ class SignRepairController extends Controller
try {
DB::beginTransaction();
if (!$service->delete($id)) {
if (! $service->delete($id)) {
throw new RuntimeException($service->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -2,9 +2,7 @@
namespace App\Http\Controllers\Api;
use App\Enums\TaskStatus;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Models\Keyword;
use App\Models\Ledger;
use App\Models\LedgerItem;
@ -220,6 +218,7 @@ class LedgerController extends Controller
$items = $lotteryTypes->map(function ($lotteryType) use ($ledgerItems) {
$ledgerItem = $ledgerItems->get($lotteryType->key);
return [
'id' => $lotteryType->key,
'name' => $lotteryType->name,

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers\Api;
use App\Filters\MessageFilter;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\MessageResource;
use App\Models\Message;
use App\Models\MessageReadingLog;
@ -37,8 +36,8 @@ class MessageController extends Controller
return [
'data' => $list,
'meta' => [
'total' => $paginator->total()
]
'total' => $paginator->total(),
],
];
}

View File

@ -3,13 +3,17 @@
namespace App\Http\Controllers\Api;
use App\Admin\Services\WorkFlowService;
use App\Enums\CheckStatus;
use App\Exceptions\RuntimeException;
use App\Http\Resources\{ReimbursementResource, WorkflowLogResource};
use App\Models\{Keyword, Reimbursement, WorkflowCheck};
use Illuminate\Http\{Request, Response};
use App\Http\Resources\ReimbursementResource;
use App\Http\Resources\WorkflowLogResource;
use App\Models\Keyword;
use App\Models\Reimbursement;
use App\Models\WorkflowCheck;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use App\Enums\CheckStatus;
use Throwable;
/**
@ -76,6 +80,7 @@ class ReimbursementController extends Controller
public function show($id, Request $request): ReimbursementResource
{
$reimbursement = Reimbursement::with(['type', 'workflow', 'employee', 'store'])->findOrFail($id);
return ReimbursementResource::make($reimbursement);
}
@ -154,8 +159,8 @@ class ReimbursementController extends Controller
{
$user = $request->user();
$query = Reimbursement::with(['workflow', 'type', 'store'])
->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
->whereHas('workflow.logs', fn($q) => $q->own($user))->orderBy('created_at', 'desc');
->whereHas('workflow', fn ($q) => $q->where('check_status', CheckStatus::Processing))
->whereHas('workflow.logs', fn ($q) => $q->own($user))->orderBy('created_at', 'desc');
$list = $query->paginate($request->input('per_page'));
@ -166,7 +171,7 @@ class ReimbursementController extends Controller
{
$request->validate([
'status' => ['required'],
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
], [
'remarks.required_if' => '未通过原因必填',
]);
@ -175,14 +180,15 @@ class ReimbursementController extends Controller
try {
DB::beginTransaction();
$log = $info->workflow->logs()->where('check_status', CheckStatus::Processing)->first();
if (!$log) {
if (! $log) {
throw new RuntimeException('审核已经完成');
}
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
throw new RuntimeException($workFlowService->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -63,6 +63,7 @@ MySQL;
return TaskResource::collection(
$tasks->through(function ($task) {
$task->taskable->setRelation('task', $task->withoutRelations());
return $task;
})
);

View File

@ -3,9 +3,9 @@
namespace App\Http\Controllers\Api\Train;
use App\Http\Controllers\Api\Controller;
use Illuminate\Http\Request;
use App\Models\Train\Book;
use App\Http\Resources\TrainBookResource;
use App\Models\Train\Book;
use Illuminate\Http\Request;
/**
* 培训-课件

View File

@ -2,14 +2,14 @@
namespace App\Http\Controllers\Api\Train;
use App\Http\Controllers\Api\Controller;
use Illuminate\Http\Request;
use App\Models\Train\{Paper, Examination};
use App\Http\Resources\{TrainExaminationResource, TrainPaperResource};
use App\Enums\ExamStatus;
use App\Admin\Services\Train\PaperService;
use Illuminate\Support\Facades\DB;
use App\Enums\ExamStatus;
use App\Exceptions\RuntimeException;
use App\Http\Controllers\Api\Controller;
use App\Http\Resources\TrainPaperResource;
use App\Models\Train\Paper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* 培训-考试
@ -21,7 +21,7 @@ class ExaminationController extends Controller
$user = $this->guard()->user();
$list = Paper::with(['examination'])
->where('employee_id', $user->id)
->whereHas('examination', fn($q) => $q->where('exam_status', ExamStatus::Published))
->whereHas('examination', fn ($q) => $q->where('exam_status', ExamStatus::Published))
->orderBy('created_at', 'desc')
->paginate($request->input('per_page'));
@ -39,18 +39,19 @@ class ExaminationController extends Controller
public function answer($id, Request $request, PaperService $service)
{
$request->validate([
'answers' => ['required', 'array']
'answers' => ['required', 'array'],
]);
$user = $this->guard()->user();
$info = Paper::with(['examination'])->where('employee_id', $user->id)->findOrFail($id);
try {
DB::beginTransaction();
if (!$service->answer($info, $request->input('answers'))) {
if (! $service->answer($info, $request->input('answers'))) {
throw new RuntimeException($service->getError());
}
DB::commit();
return TrainPaperResource::make($info);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -11,10 +11,10 @@ use App\Models\Task;
use App\Models\TaskHygiene;
use App\Models\TaskLedger;
use App\Models\WorkflowCheck;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\{Request, Response};
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
@ -39,7 +39,7 @@ class WorkflowController extends Controller
$query = $model::query()->with($include)
// ->whereHas('workflow', fn($q) => $q->where('check_status', CheckStatus::Processing))
->whereHas('workflow.logs', fn($q) => $q->own($user)->where('check_status', '>', CheckStatus::None->value))
->whereHas('workflow.logs', fn ($q) => $q->own($user)->where('check_status', '>', CheckStatus::None->value))
->orderBy('created_at', 'desc');
$list = $query->paginate($request->input('per_page'));
@ -110,11 +110,11 @@ class WorkflowController extends Controller
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
if (! $taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
if (! $check) {
throw new RuntimeException('审核记录不存在');
}
} else {
@ -134,11 +134,11 @@ class WorkflowController extends Controller
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
if (! $taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
if (! $check) {
throw new RuntimeException('审核记录不存在');
}
} else {
@ -146,11 +146,12 @@ class WorkflowController extends Controller
}
try {
DB::beginTransaction();
if (!$workFlowService->cancel($check)) {
if (! $workFlowService->cancel($check)) {
throw new RuntimeException($workFlowService->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();
@ -163,7 +164,7 @@ class WorkflowController extends Controller
$request->validate([
'subject_type' => 'required',
'status' => ['required'],
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
], [
'remarks.required_if' => '未通过原因必填',
]);
@ -171,11 +172,11 @@ class WorkflowController extends Controller
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
if (! $taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
if (! $check) {
throw new RuntimeException('审核记录不存在');
}
} else {
@ -185,14 +186,15 @@ class WorkflowController extends Controller
try {
DB::beginTransaction();
$log = $check->logs()->where('check_status', CheckStatus::Processing)->first();
if (!$log) {
if (! $log) {
throw new RuntimeException('审核已经完成');
}
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
throw new RuntimeException($workFlowService->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -8,8 +8,10 @@ use App\Exceptions\RuntimeException;
use App\Http\Resources\TaskResource;
use App\Http\Resources\WorkflowLogResource;
use App\Models\TaskHygiene;
use App\Models\{WorkflowCheck, WorkflowLog};
use Illuminate\Http\{Request, Response};
use App\Models\WorkflowCheck;
use App\Models\WorkflowLog;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
@ -36,7 +38,7 @@ class WorkflowController extends Controller
MySQL;
$list = WorkflowLog::with($include)
->whereHas('check', fn($q) => $q->where('subject_type', $subjectType))
->whereHas('check', fn ($q) => $q->where('subject_type', $subjectType))
->own($user)
->where('check_status', '>', CheckStatus::None->value)
->orderBy(DB::raw($orderBy), 'DESC')
@ -79,11 +81,12 @@ MySQL;
$check = WorkflowCheck::where('employee_id', $user->id)->findOrFail($id);
try {
DB::beginTransaction();
if (!$workFlowService->cancel($check)) {
if (! $workFlowService->cancel($check)) {
throw new RuntimeException($workFlowService->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();
@ -95,7 +98,7 @@ MySQL;
{
$request->validate([
'status' => ['required'],
'remarks' => [Rule::requiredIf(fn() => !$request->input('status'))]
'remarks' => [Rule::requiredIf(fn () => ! $request->input('status'))],
], [
'remarks.required_if' => '未通过原因必填',
]);
@ -103,11 +106,12 @@ MySQL;
$user = $this->guard()->user();
try {
DB::beginTransaction();
if (!$workFlowService->check($user, $log, !!$request->input('status'), ['remarks' => $request->input('remarks')])) {
if (! $workFlowService->check($user, $log, (bool) $request->input('status'), ['remarks' => $request->input('remarks')])) {
throw new RuntimeException($workFlowService->getError());
}
DB::commit();
return response('', Response::HTTP_OK);
} catch (\Exception $e) {
DB::rollBack();

View File

@ -5,7 +5,6 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Arr;
class CheckUserRole
{
@ -25,9 +24,10 @@ class CheckUserRole
$hasPermissions = true;
}
}
if (!$hasPermissions) {
if (! $hasPermissions) {
throw new \App\Exceptions\RuntimeException('没有权限');
}
return $next($request);
}
}

View File

@ -34,7 +34,7 @@ class HolidayApplyResource extends JsonResource
'reason' => $this->reason,
'created_at' => $this->created_at->timestamp,
'created_format' => $this->created_at->format('Y-m-d H:i:s')
'created_format' => $this->created_at->format('Y-m-d H:i:s'),
];
}
}

View File

@ -33,7 +33,7 @@ class OfficalBusinessResource extends JsonResource
'reason' => $this->reason,
'created_at' => $this->created_at->timestamp,
'created_format' => $this->created_at->format('Y-m-d H:i:s')
'created_format' => $this->created_at->format('Y-m-d H:i:s'),
];
}
}

View File

@ -4,7 +4,6 @@ namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Enums\TaskHygieneStatus;
class TaskHygieneResource extends JsonResource
{

View File

@ -2,11 +2,8 @@
namespace App\Http\Resources;
use App\Models\TaskHygiene;
use App\Models\TaskLedger;
use App\Models\TaskPerformance;
use Illuminate\Database\Eloquent\Relations\Relation;
use App\Exceptions\RuntimeException;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@ -20,6 +17,7 @@ class TaskResource extends JsonResource
public function toArray(Request $request): array
{
$resource = $this->mapResource($this->taskable_type);
return [
'id' => $this->id,
'name' => $this->name,

View File

@ -22,7 +22,7 @@ class TrainPaperResource extends JsonResource
'employee' => EmployeeResource::make($this->whenLoaded('employee')),
'content' => $this->content,
'mark' => $this->mark,
'finished_at' => $this->finished_at?->timestamp
'finished_at' => $this->finished_at?->timestamp,
];
}
}

View File

@ -2,9 +2,9 @@
namespace App\Http\Resources;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Database\Eloquent\Relations\Relation;
use RuntimeException;
class WorkflowCheckResource extends JsonResource
@ -17,6 +17,7 @@ class WorkflowCheckResource extends JsonResource
public function toArray(Request $request): array
{
$resource = $this->mapResource($this->subject_type);
return [
'id' => $this->id,
'check_status' => $this->check_status,

View File

@ -3,7 +3,6 @@
namespace App\Http\Resources;
use Illuminate\Http\Request;
use App\Enums\CheckStatus;
use Illuminate\Http\Resources\Json\JsonResource;
class WorkflowLogResource extends JsonResource

View File

@ -4,12 +4,6 @@ namespace App\Listeners;
use App\Enums\MessageType;
use App\Events\WorkflowCheckFailed;
use App\Models\EmployeePromotion;
use App\Models\EmployeeSignRepair;
use App\Models\HolidayApply;
use App\Models\OfficalBusiness;
use App\Models\OvertimeApply;
use App\Models\Reimbursement;
use App\Services\MessageService;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
@ -23,7 +17,8 @@ class CreateWorkflowCheckFailedMessage implements ShouldQueue
*/
public function __construct(
public MessageService $messageService,
) {}
) {
}
/**
* Handle the event.

View File

@ -19,7 +19,8 @@ class CreateWorkflowCheckNextMessage implements ShouldQueue
*/
public function __construct(
public MessageService $messageService,
) {}
) {
}
/**
* Handle the event.

View File

@ -17,7 +17,8 @@ class CreateWorkflowCheckSuccessMessage implements ShouldQueue
*/
public function __construct(
public MessageService $messageService,
) {}
) {
}
/**
* Handle the event.

View File

@ -40,15 +40,15 @@ class SendWorkflowCheckFailedNotification implements ShouldQueue
$client = new EasySms(config('easysms'));
$client->send($phone, [
'content' => function($gateway) use ($applyAt, $subjectTypeText) {
'content' => function ($gateway) use ($applyAt, $subjectTypeText) {
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}未通过审批,请登录查看。";
},
'template' => function($gateway) {
'template' => function ($gateway) {
if ($gateway->getName() == 'aliyun') {
return 'SMS_465905330';
}
},
'data' => function($gateway) use ($applyAt, $subjectTypeText) {
'data' => function ($gateway) use ($applyAt, $subjectTypeText) {
return [
'time' => $applyAt->toDateString(),
'work_msg' => $subjectTypeText,

View File

@ -54,15 +54,15 @@ class SendWorkflowCheckNextNotification implements ShouldQueue
foreach ($employees as $employee) {
try {
$client->send($employee->phone, [
'content' => function($gateway) use ($subjectTypeText) {
'content' => function ($gateway) use ($subjectTypeText) {
return "您有一条{$subjectTypeText}待处理,请尽快登录处理。";
},
'template' => function($gateway) {
'template' => function ($gateway) {
if ($gateway->getName() == 'aliyun') {
return 'SMS_465900349';
}
},
'data' => function($gateway) use ($subjectTypeText) {
'data' => function ($gateway) use ($subjectTypeText) {
return [
'work_msg' => $subjectTypeText,
];

View File

@ -40,15 +40,15 @@ class SendWorkflowCheckSuccessNotification implements ShouldQueue
$client = new EasySms(config('easysms'));
$client->send($phone, [
'content' => function($gateway) use ($applyAt, $subjectTypeText) {
'content' => function ($gateway) use ($applyAt, $subjectTypeText) {
return "您于{$applyAt->toDateString()}提交的{$subjectTypeText}已通过审批,请登录查看。";
},
'template' => function($gateway) {
'template' => function ($gateway) {
if ($gateway->getName() == 'aliyun') {
return 'SMS_465955319';
}
},
'data' => function($gateway) use ($applyAt, $subjectTypeText) {
'data' => function ($gateway) use ($applyAt, $subjectTypeText) {
return [
'time' => $applyAt->toDateString(),
'work_msg' => $subjectTypeText,

View File

@ -2,18 +2,17 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Traits\HasCheckable;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use App\Traits\HasCheckable;
use Illuminate\Database\Eloquent\Model;
/**
* 合同
*/
class Agreement extends Model
{
use HasDateTimeFormatter, Filterable, HasCheckable;
use Filterable, HasCheckable, HasDateTimeFormatter;
protected $fillable = ['name', 'employee_id', 'store_id', 'images', 'remarks'];

View File

@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model;
class AppVersion extends Model
{
use Filterable, HasFactory, HasDateTimeFormatter;
use Filterable, HasDateTimeFormatter, HasFactory;
protected $appends = [
'is_release',
@ -76,6 +76,7 @@ class AppVersion extends Model
if ((string) $value === '') {
$value = null;
}
return $value;
},
);
@ -88,6 +89,7 @@ class AppVersion extends Model
if ((string) $value === '') {
$value = null;
}
return $value;
},
);

View File

@ -4,16 +4,15 @@ namespace App\Models;
use App\Admin\Filters\EmployeeFilter;
use App\Enums\EmployeeStatus;
use App\Enums\UserRole;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Laravel\Sanctum\HasApiTokens;
use App\Models\AdminUser;
use App\Enums\UserRole;
use Illuminate\Database\Eloquent\Builder;
/**
* 员工
@ -53,7 +52,7 @@ class Employee extends Model implements AuthenticatableContract
public function avatar(): Attribute
{
return Attribute::make(
get: fn($value) => $value ? $value : url(config('admin.default_avatar')),
get: fn ($value) => $value ? $value : url(config('admin.default_avatar')),
);
}
@ -136,7 +135,6 @@ class Employee extends Model implements AuthenticatableContract
/**
* 用户身份
* user: 普通员工, store: 店长, admin: 管理员, store_user: 店员
* @return array
*/
public function userRole(): array
{

View File

@ -7,7 +7,6 @@ use App\Traits\HasCheckable;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
/**
* 员工升职申请

View File

@ -2,13 +2,13 @@
namespace App\Models;
use App\Enums\{SignTime, SignType, CheckStatus};
use App\Admin\Services\EmployeeSignService;
use App\Enums\SignTime;
use App\Enums\SignType;
use App\Traits\HasCheckable;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;
use App\Models\EmployeeSignLog;
use App\Admin\Services\EmployeeSignService;
/**
* 补卡申请

View File

@ -3,7 +3,8 @@
namespace App\Models;
use App\Enums\{CheckStatus};
use App\Traits\{HasCheckable, HasDateTimeFormatter};
use App\Traits\HasCheckable;
use App\Traits\HasDateTimeFormatter;
use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Model;

View File

@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
class Plan extends Model
{
use Filterable, HasFactory, HasDateTimeFormatter;
use Filterable, HasDateTimeFormatter, HasFactory;
protected $attributes = [
'plan_status' => PlanStatus::Pending,

View File

@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\MorphOne;
class PlanLedger extends Model
{
use HasFactory, HasDateTimeFormatter;
use HasDateTimeFormatter, HasFactory;
protected $fillable = [
'date',
@ -20,4 +20,3 @@ class PlanLedger extends Model
return $this->morphOne(Plan::class, 'planable');
}
}

View File

@ -84,7 +84,7 @@ class Store extends Model
*/
public function isLotteryStore(): bool
{
return 'store_category_lottery' === $this->category_id || preg_match('/^store_category_lottery_/', $this->category_id);
return $this->category_id === 'store_category_lottery' || preg_match('/^store_category_lottery_/', $this->category_id);
}
protected function businessStatusText(): Attribute

View File

@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StoreProfitRatioLog extends Model
{
use Filterable, HasFactory, HasDateTimeFormatter;
use Filterable, HasDateTimeFormatter, HasFactory;
protected $fillable = [
'store_id',

View File

@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
class Task extends Model
{
use Filterable, HasFactory, HasDateTimeFormatter;
use Filterable, HasDateTimeFormatter, HasFactory;
protected $attributes = [
'task_status' => TaskStatus::Pending,

View File

@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\MorphOne;
class TaskHygiene extends Model
{
use HasCheckable, HasFactory, HasDateTimeFormatter;
use HasCheckable, HasDateTimeFormatter, HasFactory;
protected $appends = [
'task_status',

View File

@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\MorphOne;
class TaskLedger extends Model
{
use HasFactory, HasDateTimeFormatter;
use HasDateTimeFormatter, HasFactory;
protected $appends = [
'task_status',

View File

@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Relations\MorphOne;
class TaskPerformance extends Model
{
use HasFactory, HasDateTimeFormatter;
use HasDateTimeFormatter, HasFactory;
protected $appends = [
'task_status',

Some files were not shown because too many files have changed in this diff Show More