app/Http/Controllers/Admin/teacherController.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(TeacherValidator $request)
    {
        if ($request->hasFile('image')) {
            $image = $request->file('image');
            $teach = "image-" . time() . '.' . $image->getClientOriginalExtension();
            $image->move('images/teacher/', $teach);
            }
            $teacher = new Teacher([
                'fname' => $request->fname,
                'lname' => $request->lname,
                'email'   => $request->email,
                'teachcat' => $request->teachcat,
                'teachtime' => $request->teachtime,
                'phone' => $request->phone,
                'batch' => $request->batch,
                'course' => $request->course,
                'address' => $request->address
            ]);
            $teacher->image = $teach;
            $teacher->save();
        return redirect()->route('teacher.index')->with('success', 'Teacher Created successfully');
    }
public function store ( TeacherValidator $ request ) { if ( $ request -> hasFile ( 'image' ) ) { $ image = $ request -> file ( 'image' ) ; $ teach = " image- " . time ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( 'images/teacher/' , $ teach ) ; } $ teacher = new Teacher ( [ 'fname' => $ request -> fname , 'lname' => $ request -> lname , 'email' => $ request -> email , 'teachcat' => $ request -> teachcat , 'teachtime' => $ request -> teachtime , 'phone' => $ request -> phone , 'batch' => $ request -> batch , 'course' => $ request -> course , 'address' => $ request -> address ] ) ; $ teacher -> image = $ teach ; $ teacher -> save ( ) ; return redirect ( ) -> route ( 'teacher.index' ) -> with ( 'success' , 'Teacher Created successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .