예제 #1
0
 public function add(Request $request)
 {
     $me = \Session::get('user');
     if (!$me->can('项目外出记录管理')) {
         abort(401);
     }
     $user = User::find($request->input('user_id'));
     $record = new Record();
     $project = Project::find($request->input('project_id'));
     $record->project()->associate($project);
     $record->user()->associate($user);
     $time = $request->input('time');
     if (!$time) {
         $time = null;
     } else {
         $time = \Carbon\Carbon::createFromFormat('Y/m/d', $time)->format('Y-m-d H:i:s');
     }
     $record->time = $time;
     $record->content = $request->input('content');
     $record->contact = $request->input('contact');
     $record->phone = $request->input('phone');
     $record->software_count = $request->input('software_count');
     $record->hardware_name = $request->input('hardware_name');
     $record->hardware_count = $request->input('hardware_count');
     $record->save();
     \Log::notice(strtr('外出记录添加: 用户(%name[%id]) 添加了项目 %project[%project_id] 的外出记录 %record_id', ['%name' => $me->name, '%id' => $me->id, '%project' => $project->name, '%project_id' => $project->id, '%record_id' => $record->id]));
     return redirect()->back()->with('message_content', '外出记录添加成功!')->with('message_type', 'info')->with('tab', 'records');
 }