添加农作物产量管理操作日志

dev
vine_liutk 2022-11-15 10:01:13 +08:00
parent ed817193c0
commit faf5e36069
1 changed files with 9 additions and 1 deletions

View File

@ -11,6 +11,8 @@ use App\Models\CropYield;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Peidikeji\Keywords\Models\Keywords;
use App\Services\OperationLogService;
use App\Enums\OperationType;
class CropYieldController extends Controller
{
@ -42,12 +44,14 @@ class CropYieldController extends Controller
$crop = Crop::find($cropId);
CropYield::create(array_merge($request->input(), [
$cropYield = CropYield::create(array_merge($request->input(), [
'category_id' => $crop->category_id ?? 0,
'created_by' => auth('api')->user()?->id ?? 0,
'updated_by' => auth('api')->user()?->id ?? 0,
]));
(new OperationLogService())->inLog(OperationType::Create, '', $cropYield, $request->input());
return $this->success('添加成功');
}
@ -80,6 +84,8 @@ class CropYieldController extends Controller
'updated_by' => auth('api')->user()?->id ?? 0,
]));
(new OperationLogService())->inLog(OperationType::Update, '', $cropYield, $request->input());
return $this->success('修改成功');
}
@ -87,6 +93,8 @@ class CropYieldController extends Controller
{
$cropYield->delete();
(new OperationLogService())->inLog(OperationType::Delete, '', $cropYield);
return $this->success('删除成功');
}