app/Http/Controllers/Admin/todoController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(ToDoValidator $request)
    {
        if ($request->hasFile('fileUpload')) {
            $image = $request->file('fileUpload');
            $fileUploads = "photo-" . time() . '.' . $image->getClientOriginalExtension();
            $image->move('images/taskfile/', $fileUploads);
            }
            $todo = new Todo([
                'title' => $request->title,                        
                'description' => $request->description,
                'assignedDate'   => $request->assignedDate,
                'assignedTo' => $request->assignedTo,
                'deadline' => $request->deadline,
                'task_priority' => $request->task_priority,
                'remarks' => $request->remarks,
                'assignedBy' => $request->assignedBy,
                'Reassignedby'=> $request->Reassignedby,
                'Reassignedto'=>$request->Reassignedto,
                'Reassigneddate'=>$request->Reassigneddate,
                'Redeadline'=>$request->Redeadline,
                'reason'=>$request->reason,
                'status'=>$request->status,
                'remarks'=>$request->remarks,
                'user_id'=>$request->user_id,
                'Reuser_id'=>$request->Reuser_id
            ]);
            $todo->fileUpload = $fileUploads;
        $todos=$todo->save();
        $assignedTo = User::findOrfail($request->assignedTo);
        $thread = [
            'assignedTo' => auth()->user()->name,
            'assignedBy' => $request->name,
        ];
        $assignedTo->notify(new \App\Notifications\TaskNotification($thread));
        Mail::to($todo->staff->email)->send(new TodoAssignMail());
        if ($todos) {
            if (Auth::user()->roles->name == 'admin') {
                return redirect()->route('assignTask')->with('success', 'New Task Assigned Successfully');
            } else {
                return redirect()->route('todo.index')->with('success', 'New Task Assigned Successfully');
            }
        } else {
            return redirect()->back()->with('error', 'Oops!!! some error occurred');
        }
        return redirect()->route('todo.index')->with('success', 'ToDo Created Successfully');
    }
public function store ( ToDoValidator $ request ) { if ( $ request -> hasFile ( 'fileUpload' ) ) { $ image = $ request -> file ( 'fileUpload' ) ; $ fileUploads = " photo- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/taskfile/' , $ fileUploads ) ; } $ todo = new Todo ( [ 'title' => $ request -> title , 'description' => $ request -> description , 'assignedDate' => $ request -> assignedDate , 'assignedTo' => $ request -> assignedTo , 'deadline' => $ request -> deadline , 'task_priority' => $ request -> task_priority , 'remarks' => $ request -> remarks , 'assignedBy' => $ request -> assignedBy , 'Reassignedby' => $ request -> Reassignedby , 'Reassignedto' => $ request -> Reassignedto , 'Reassigneddate' => $ request -> Reassigneddate , 'Redeadline' => $ request -> Redeadline , 'reason' => $ request -> reason , 'status' => $ request -> status , 'remarks' => $ request -> remarks , 'user_id' => $ request -> user_id , 'Reuser_id' => $ request -> Reuser_id ] ) ; $ todo -> fileUpload = $ fileUploads ; $ todos = $ todo -> save ( ) ; $ assignedTo = User :: findOrfail ( $ request -> assignedTo ) ; $ thread = [ 'assignedTo' => auth ( ) -> user ( ) -> name , 'assignedBy' => $ request -> name , ] ; $ assignedTo -> notify ( new \ App \ Notifications \ TaskNotification ( $ thread ) ) ; Mail :: to ( $ todo -> staff -> email ) -> send ( new TodoAssignMail ( ) ) ; if ( $ todos ) { if ( Auth :: user ( ) -> roles -> name == 'admin' ) { return redirect ( ) -> route ( 'assignTask' ) -> with ( 'success' , 'New Task Assigned Successfully' ) ; } else { return redirect ( ) -> route ( 'todo.index' ) -> with ( 'success' , 'New Task Assigned Successfully' ) ; } } else { return redirect ( ) -> back ( ) -> with ( 'error' , 'Oops!!! some error occurred' ) ; } return redirect ( ) -> route ( 'todo.index' ) -> with ( 'success' , 'ToDo Created Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//dd($todo);