liyinglin 3 years ago
parent 5fe3d1fc34
commit 23658df1bb

@ -330,6 +330,13 @@ class ProjectController extends CommonController
public function askSubmitStore(Request $request) public function askSubmitStore(Request $request)
{ {
$all = \request()->all(); $all = \request()->all();
$userId = auth()->user()->id;
// 一个月只能提交一次
$has = AskSubmit::where('admin_id', $userId)
->where('project_id', $all['project_id'])
->where('date', 'like', '%' . date('Y-m') . '%')
->first();
if ($has) return $this->error("每个月只能提交一次");
$content = []; $content = [];
$socre = 0; $socre = 0;
foreach ($all['ask'] as $key => $item) { foreach ($all['ask'] as $key => $item) {
@ -339,7 +346,7 @@ class ProjectController extends CommonController
]; ];
$socre += $item; $socre += $item;
} }
$all['admin_id'] = auth()->user()->id; $all['admin_id'] = $userId;
$all['score'] = $socre; $all['score'] = $socre;
$all['content'] = $content; $all['content'] = $content;
$model = AskSubmit::create($all); $model = AskSubmit::create($all);
@ -389,10 +396,10 @@ class ProjectController extends CommonController
public function delete(Request $request) public function delete(Request $request)
{ {
try { try {
$array = explode('-',$request->id); $array = explode('-', $request->id);
if(count($array) == 2){ if (count($array) == 2) {
$model = AskSubmit::find($array[1]); $model = AskSubmit::find($array[1]);
}else{ } else {
$model = $this->model->find($request->id); $model = $this->model->find($request->id);
} }
$model->delete(); $model->delete();

Loading…
Cancel
Save