app/Http/Controllers/Admin/teacherController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(TeacherValidator $request, $id)
    {
        $teacher = Teacher::findorfail($id);
        if ($request->hasFile('image')) {
            $new_img = $request->file('image');
            $name = "image-" . time() .'.'. $new_img->getClientOriginalExtension();
            $new_img->move('images/teacher/',$name);
            $teacher->image = $name;    
        }else{
            $teacher->image = Auth::user()->image;
        }
            $teacher->fname = $request->input('fname');
            $teacher->lname = $request->input('lname');
            $teacher->email = $request->input('email');
            $teacher->teachcat = $request->input('teachcat');
            $teacher->phone = $request->input('phone');
            $teacher->teachtime = $request->input('teachtime');
            $teacher->batch = $request->input('batch');
            $teacher->course = $request->input('course');
            $teacher->address = $request->input('address');
            $teacher->save();
        return redirect()->route('teacher.index')->with('success', 'Teacher Updated Successfully');
    }
public function update ( TeacherValidator $ request , $ id ) { $ teacher = Teacher :: findorfail ( $ id ) ; if ( $ request -> hasFile ( 'image' ) ) { $ new_img = $ request -> file ( 'image' ) ; $ name = " image- " . time ( ) . '.' . $ new_img -> getClientOriginalExtension ( ) ; $ new_img -> move ( 'images/teacher/' , $ name ) ; $ teacher -> image = $ name ; } else { $ teacher -> image = Auth :: user ( ) -> image ; } $ teacher -> fname = $ request -> input ( 'fname' ) ; $ teacher -> lname = $ request -> input ( 'lname' ) ; $ teacher -> email = $ request -> input ( 'email' ) ; $ teacher -> teachcat = $ request -> input ( 'teachcat' ) ; $ teacher -> phone = $ request -> input ( 'phone' ) ; $ teacher -> teachtime = $ request -> input ( 'teachtime' ) ; $ teacher -> batch = $ request -> input ( 'batch' ) ; $ teacher -> course = $ request -> input ( 'course' ) ; $ teacher -> address = $ request -> input ( 'address' ) ; $ teacher -> save ( ) ; return redirect ( ) -> route ( 'teacher.index' ) -> with ( 'success' , 'Teacher Updated Successfully' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .