Javascript Laravel-动态输入字段提交失败,未显示任何错误
我已经和这个问题斗争了好几天了。我有一个关于Laravel-5.8的项目 我有两个模型课 评价的Javascript Laravel-动态输入字段提交失败,未显示任何错误,javascript,laravel,Javascript,Laravel,我已经和这个问题斗争了好几天了。我有一个关于Laravel-5.8的项目 我有两个模型课 评价的 protected $fillable = [ 'goal_type_id', 'appraisal_identity_id', 'employee_id', 'company_id', 'is_published', 'is_approved', 'weigh
protected $fillable = [
'goal_type_id',
'appraisal_identity_id',
'employee_id',
'company_id',
'is_published',
'is_approved',
'weighted_score',
'employee_comment',
'line_manager_comment',
'goal_title',
'start_date',
'end_date',
'created_by',
'created_at',
'updated_by',
'updated_at',
'is_active'
];
AlgoAlDetail
protected $fillable = [
'name',
'company_id',
'appraisal_goal_id',
'kpi_description',
'appraisal_doc',
'activity',
'created_by',
'created_at',
'updated_by',
'updated_at',
'is_active'
];
评价目标是主要模型
存储请求
class StoreAppraisalGoalRequest extends FormRequest
{
public function rules()
{
return [
'goal_title' => 'required|min:5|max:100',
'goal_type_id' => 'required',
'weighted_score' => 'required|numeric|min:0|max:500',
'start_date' => 'required',
'end_date' => 'required|after_or_equal:start_date',
'appraisal_goal_id' => 'required',
'kpi_description' => 'required|max:300',
'activity' => 'required|max:300',
];
}
}
控制器
public function create()
{
$userCompany = Auth::user()->company_id;
$identities = DB::table('appraisal_identity')->select('appraisal_name')->where('company_id', $userCompany)->where('is_current', 1)->first();
$goaltypes = AppraisalGoalType::where('company_id', $userCompany)->get();
$categories = AppraisalGoalType::with('children')->where('company_id', $userCompany)->whereNull('parent_id')->get();
return view('appraisal.appraisal_goals.create')
->with('goaltypes', $goaltypes)
->with('categories', $categories)
->with('identities', $identities);
}
public function store(StoreAppraisalGoalRequest $request)
{
$startDate = Carbon::parse($request->start_date);
$endDate = Carbon::parse($request->end_date);
$userCompany = Auth::user()->company_id;
$appraisal_identity_id = AppraisalIdentity::where('company_id', $userCompany)->where('is_current',1)->value('id');
try {
$goal = new AppraisalGoal();
$goal->goal_type_id = $request->goal_type_id;
$goal->appraisal_identity_id = $appraisal_identity_id;
$goal->employee_id = $request->employee_id;
$goal->weighted_score = $request->weighted_score;
$goal->goal_description = $request->goal_description;
$goal->start_date = $startDate;
$goal->end_date = $endDate;
$goal->company_id = Auth::user()->company_id;
$goal->created_by = Auth::user()->id;
$goal->created_at = date("Y-m-d H:i:s");
$goal->is_active = 1;
$goal->save();
foreach ( $request->activity as $key => $activity){
$goaldetail = new AppraisalGoalDetail();
$goaldetail->kpi_description = $request->kpi_description[$key];
$goaldetail->appraisal_doc = $request->application_doc[$key];
$goaldetail->activity = $request->activity[$key];
$goaldetail->appraisal_goal_id = $goal->id;
$goaldetail->company_id = Auth::user()->company_id;
$goaldetail->created_by = Auth::user()->id;
$goaldetail->created_at = date("Y-m-d H:i:s");
$goaldetail->is_active = 1;
$goaldetail->save();
}
Session::flash('success', 'Appraisal Goal is created successfully');
return redirect()->route('appraisal.appraisal_goals.index');
} catch (Exception $exception) {
Session::flash('danger', 'Appraisal Goal creation failed!');
return redirect()->route('appraisal.appraisal_goals.index');
}
}
创建新刀片
创建我的3+1目标:{{$identies->evaluation_name}
@csrf
目标类型:*
选择目标类型
@foreach($categories作为$category)
@除非($category->name===‘工作基础’)
id==old('category_id')?'所选“:”}>{{$category->name}
@如果($category->children)
@foreach($category->children as$child)
@除非($child->name==‘工作基础’)
id==old('category_id')?'所选“:”}>{{$child->name}
@结束语
@endforeach
@恩迪夫
@结束语
@endforeach
目标名称:*
目标描述
活动*
KPI说明*
附件
选择文件
重量:
开始日期:*
结束日期:*
{{trans('global.save')}
取消
有时一些开发人员使用try-catch语句,但在代码引发异常时忘记查看错误。因此,让我们将您的catch语句更改为此,以找出问题所在
}catch (Exception $exception) {
dd($exception->getMessage());
Session::flash('danger', 'Appraisal Goal creation failed!');
return redirect()->route('appraisal.appraisal_goals.index');
}
在
catch
语句中,您可以使用dd($exception->getMessage())查看异常代码>@M.fahmiullazmi-非常感谢。你解决了这个问题。我注意到有一个必填字段:employee_comment。Thanks@mikefolu你能让法赫米提交答案并接受吗?使问答页面更清晰,以防其他人遇到类似问题。谢谢