Пример #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\TasklogRequest $request)
 {
     //
     if ($request->hasFile('attachment')) {
         $tasklog = $request->except(['_token', 'attachment']);
         $date = Carbon::now()->format('Y_m_d');
         $path = base_path() . '/up/TASK/' . $date;
         $ext = $request->file('attachment')->getClientOriginalExtension();
         $step_id = TaskStep::find($tasklog['step_id'])->first()->value('id');
         $time = Carbon::now()->timestamp;
         $filename = "TASK_" . $step_id . "_" . $time . "." . $ext;
         $request->file('attachment')->move($path, $filename);
         $tasklog['attachment'] = $path . "/" . $filename;
         $tasklog = TaskLog::create($tasklog);
         Task::find($tasklog['task_id'])->update(['step_id' => $tasklog['step_id']]);
     }
     // return back();
     return redirect()->to('tasks');
 }
Пример #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $steps = TaskStep::all();
     return view('task.step', compact('steps'));
 }