Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(TaskRequest $request)
 {
     //
     if ($request->hasFile('attachment')) {
         $data = $request->except(['_token', 'attachment']);
         $task = Task::create($data);
         $date = Carbon::now()->format('Y_m_d');
         $path = base_path() . '/up/TASK/' . $date;
         $ext = $request->file('attachment')->getClientOriginalExtension();
         $filename = "TASK_INIT" . Carbon::now()->timestamp . "." . $ext;
         $request->file('attachment')->move($path, $filename);
         $tasklog['task_id'] = $task->id;
         $tasklog['step_id'] = $task->step_id;
         $tasklog['attachment'] = $path . "/" . $filename;
         TaskLog::create($tasklog);
     }
     return back();
 }