app/Http/Controllers/Member/MemberController.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(Request $request, $slag)
    {
        $model_common = new CommonModel();
        $ImgName =  $model_common->ImageName();
        $user_id =Auth::user()->id;
        $member = Member::where('slag',$slag)->first();
        $member->name=$request->name;
        $member->mobile=$request->phone;
        $member->ledgerid=$request->ledgerid;
        $member->father_name=$request->father_name;
        $member->husband_name=$request->husband_name;
        $member->occupation=$request->income_source;
        $member->present_address=$request->present_address;
        $member->permanent_address=$request->permanent_address;
        $member->user_id=$user_id;
        $member->save();
        $member_nuid = NidImage::where('member_id',$member->id)->first();
        $member_nuid->nuid_no=$request->nid_no;
        $nuidimage = $request->nid_image;
        if($request->hasFile('nid_image')){
            if ($member_nuid->nuid_image !=null){
                $path = 'Media/Member_NUID/' . $member_nuid->nuid_image;
                unlink($path);
            }
            $nuidimageFilename = time() . $ImgName . $nuidimage->getClientOriginalExtension();
            Image::make($nuidimage->getRealPath())->resize(450, 300)->save(public_path('/Media/Member_NUID/'.$nuidimageFilename));
            $member_nuid->nuid_image=$nuidimageFilename;
        }
        $avatarimage = $request->avatar_image;
        if($request->hasFile('avatar_image')){
            if ($member_nuid->member_image !=null){
                $path = 'Media/Member_Avature/' . $member_nuid->member_image;
                unlink($path);
            }
            $avatarimageFilename = time() . $ImgName . $avatarimage->getClientOriginalExtension();
            Image::make($avatarimage->getRealPath())->resize(300, 350)->save(public_path('/Media/Member_Avature/'.$avatarimageFilename));
            $member_nuid->member_image=$avatarimageFilename;
        }
        $member_nuid->save();
        $nominess = Nominee::where('member_id',$member->id)->first();
        if ($nominess==null){
            $nominess = new Nominee();
            $nominess->member_id=$member->id;
            $nominess->name=$request->nominee;
            $nominess->age=$request->nomineeage;
            $nominess->relation=$request->nomineerelation;
            $nominess->father_name=$request->nomineefather;
            $nominess->save();
        }else{
            $nominess = Nominee::find($nominess->id);
            $nominess->member_id=$member->id;
            $nominess->name=$request->nominee;
            $nominess->age=$request->nomineeage;
            $nominess->relation=$request->nomineerelation;
            $nominess->father_name=$request->nomineefather;
            $nominess->save();
        }
        $notification = array(
            'message' => 'Member has been Update successfully!',
            'alert-type' => 'success'
        );
        return back()->with($notification);
    }
public function update ( Request $ request , $ slag ) { $ model_common = new CommonModel ( ) ; $ ImgName = $ model_common -> ImageName ( ) ; $ user_id = Auth :: user ( ) -> id ; $ member = Member :: where ( 'slag' , $ slag ) -> first ( ) ; $ member -> name = $ request -> name ; $ member -> mobile = $ request -> phone ; $ member -> ledgerid = $ request -> ledgerid ; $ member -> father_name = $ request -> father_name ; $ member -> husband_name = $ request -> husband_name ; $ member -> occupation = $ request -> income_source ; $ member -> present_address = $ request -> present_address ; $ member -> permanent_address = $ request -> permanent_address ; $ member -> user_id = $ user_id ; $ member -> save ( ) ; $ member_nuid = NidImage :: where ( 'member_id' , $ member -> id ) -> first ( ) ; $ member_nuid -> nuid_no = $ request -> nid_no ; $ nuidimage = $ request -> nid_image ; if ( $ request -> hasFile ( 'nid_image' ) ) { if ( $ member_nuid -> nuid_image != null ) { $ path = 'Media/Member_NUID/' . $ member_nuid -> nuid_image ; unlink ( $ path ) ; } $ nuidimageFilename = time ( ) . $ ImgName . $ nuidimage -> getClientOriginalExtension ( ) ; Image :: make ( $ nuidimage -> getRealPath ( ) ) -> resize ( 450 , 300 ) -> save ( public_path ( '/Media/Member_NUID/' . $ nuidimageFilename ) ) ; $ member_nuid -> nuid_image = $ nuidimageFilename ; } $ avatarimage = $ request -> avatar_image ; if ( $ request -> hasFile ( 'avatar_image' ) ) { if ( $ member_nuid -> member_image != null ) { $ path = 'Media/Member_Avature/' . $ member_nuid -> member_image ; unlink ( $ path ) ; } $ avatarimageFilename = time ( ) . $ ImgName . $ avatarimage -> getClientOriginalExtension ( ) ; Image :: make ( $ avatarimage -> getRealPath ( ) ) -> resize ( 300 , 350 ) -> save ( public_path ( '/Media/Member_Avature/' . $ avatarimageFilename ) ) ; $ member_nuid -> member_image = $ avatarimageFilename ; } $ member_nuid -> save ( ) ; $ nominess = Nominee :: where ( 'member_id' , $ member -> id ) -> first ( ) ; if ( $ nominess == null ) { $ nominess = new Nominee ( ) ; $ nominess -> member_id = $ member -> id ; $ nominess -> name = $ request -> nominee ; $ nominess -> age = $ request -> nomineeage ; $ nominess -> relation = $ request -> nomineerelation ; $ nominess -> father_name = $ request -> nomineefather ; $ nominess -> save ( ) ; } else { $ nominess = Nominee :: find ( $ nominess -> id ) ; $ nominess -> member_id = $ member -> id ; $ nominess -> name = $ request -> nominee ; $ nominess -> age = $ request -> nomineeage ; $ nominess -> relation = $ request -> nomineerelation ; $ nominess -> father_name = $ request -> nomineefather ; $ nominess -> save ( ) ; } $ notification = array ( 'message' => 'Member has been Update successfully!' , 'alert-type' => 'success' ) ; return back ( ) -> with ( $ notification ) ; }
Update the specified resource in storage.
Update the specified resource in storage .