app/Http/Controllers/dashboard/teachers/TasksController.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(Request $request, $subject_id)
    {
        $request->validate([
            "name" => ["required"],
            "description" => ['required'],
            "deadline" => ['required', 'date']
        ]);
        $data = [
            "task_name" => $request->post('name'),
            "description" => $request->post('description'),
            "deadline" => $request->post('deadline'),
            "subject_id" => $subject_id,
        ];
        $response = new Tasks($data);
        if (!$response->save()) return back()->with('error', 'try again');
        return redirect(route('teachers-tasks.show', ["subject" => $subject_id]))->with('success', 'new tasks was create');
    }
public function store ( Request $ request , $ subject_id ) { $ request -> validate ( [ " name " => [ " required " ] , " description " => [ 'required' ] , " deadline " => [ 'required' , 'date' ] ] ) ; $ data = [ " task_name " => $ request -> post ( 'name' ) , " description " => $ request -> post ( 'description' ) , " deadline " => $ request -> post ( 'deadline' ) , " subject_id " => $ subject_id , ] ; $ response = new Tasks ( $ data ) ; if ( ! $ response -> save ( ) ) return back ( ) -> with ( 'error' , 'try again' ) ; return redirect ( route ( 'teachers-tasks.show' , [ " subject " => $ subject_id ] ) ) -> with ( 'success' , 'new tasks was create' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .