/** * 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(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Requests\TaskLogRequest $request) { // $data = $request->except(['_token', 'attachment']); if ($request->hasFile('attachment')) { $data = $request->except(['_token', 'attachment']); $date = Carbon::now()->format("Y_m_d"); $path = base_path() . "/up/" . "TASK/" . $date . "/"; $ext = $request->file('attachment')->getClientOriginalExtension(); $extmine = $request->file('attachment')->getClientMimeType(); $request->file('attachment')->move($path, Carbon::now()->timestamp . "." . $ext); $filename = $path . Carbon::now()->timestamp . "." . $ext; $data['attachment'] = $filename; } $data['company_id'] = Task::find($request->get('task_id'))->company->id; $tasklog = TaskLog::create($data); $task = $tasklog->task->update(['step_id' => $data['step_id']]); //$task=$tasklog->task; // dd($task); return redirect()->to('task'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Requests\TaskCreateRequest $request) { // if ($request->hasFile('attachment')) { $data = $request->except(['_token', 'attachment']); $date = Carbon::now()->format("Y_m_d"); $path = base_path() . "/up/" . "TASK/" . $date . "/"; $ext = $request->file('attachment')->getClientOriginalExtension(); $extmine = $request->file('attachment')->getClientMimeType(); $request->file('attachment')->move($path, Carbon::now()->timestamp . "." . $ext); $filename = $path . Carbon::now()->timestamp . "." . $ext; $data['attachment'] = $filename; $data['step_id'] = 1; $data['status_id'] = 1; $task = Task::create($data); $tasklog['step_id'] = 1; $tasklog['task_id'] = $task->id; $tasklog['company_id'] = $task->company_id; $tasklog['task_file'] = $task->attachment; $tasklog['remark'] = "发起"; TaskLog::create($tasklog); return back(); } }
public function timeline($id) { $tasklogs = TaskLog::with('step', 'task')->where('task_id', $id)->get(); $task = Task::find($id); return view('task.timeline')->with('tasklogs', $tasklogs)->with('task', $task); }
public function tasklog($id) { $path = TaskLog::find($id)->attachment; return response()->download($path); }