app/Http/Controllers/Member/MemberController.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)
    {
        $this->validate($request,[
            'name' => 'required',
            'phone' => 'required|min:11|max:14',
            'father_name' => 'required',
            'income_source' => 'required',
            'nid_no' => 'required|min:10|max:17',
            'present_address' => 'required',
            'permanent_address' => 'required',
            'nid_image' => 'required',
        ]);
        $model_common = new CommonModel();
        $slag =  $model_common->slagdata();
        $ImgName =  $model_common->ImageName();
        $SavingAcno =  $model_common->SavingAcno();
        $time = time();
        $current = new Carbon();
        $date =  $current->format('Y-m-d');
        $user_id =Auth::user()->id;
        $member = new Member();
        $member->member_no="#".$time;
        $member->ledgerid=$request->ledgerid;
        $member->name=$request->name;
        $member->mobile=$request->phone;
        $member->father_name=$request->father_name;
        $member->husband_name=$request->husband_name;
        $member->mother_name=$request->mothername;
        $member->occupation=$request->income_source;
        $member->age=$request->memberage;
        $member->gender=$request->gender;
        $member->religion=$request->religion;
        $member->marital_status=$request->Maritalstatus;
        $member->present_address=$request->present_address;
        $member->permanent_address=$request->permanent_address;
        $member->join_date=$date;
        $member->status="0";
        $member->slag=$slag;
        $member->user_id=$user_id;
        $member->save();
        $memberid = $member->id;
        $member_nuid = new NidImage();
        $member_nuid->member_id=$memberid;
        $member_nuid->nuid_no=$request->nid_no;
        $nuidimage = $request->nid_image;
        if($request->hasFile('nid_image')){
            $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')){
            $avatarimageFilename = time() . $ImgName . $avatarimage->getClientOriginalExtension();
            Image::make($avatarimage->getRealPath())->resize(300, 300)->save(public_path('/Media/Member_Avature/'.$avatarimageFilename));
            $member_nuid->member_image=$avatarimageFilename;
        }
        $member_nuid->save();
        $saving = new Saving();
        $saving->member_id=$memberid;
        $saving->savings_no=$SavingAcno;
        $saving->opening_date=$date;
        $saving->save();
        $memberaccount = new MemberAccount();
        $memberaccount->member_id=$memberid;
        $memberaccount->saving_id=$SavingAcno;
        $memberaccount->save();
        $nominess = new Nominee();
        $nominess->member_id=$memberid;
        $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 created successfully!',
            'alert-type' => 'success'
        );
        return back()->with($notification);
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required' , 'phone' => 'required|min:11|max:14' , 'father_name' => 'required' , 'income_source' => 'required' , 'nid_no' => 'required|min:10|max:17' , 'present_address' => 'required' , 'permanent_address' => 'required' , 'nid_image' => 'required' , ] ) ; $ model_common = new CommonModel ( ) ; $ slag = $ model_common -> slagdata ( ) ; $ ImgName = $ model_common -> ImageName ( ) ; $ SavingAcno = $ model_common -> SavingAcno ( ) ; $ time = time ( ) ; $ current = new Carbon ( ) ; $ date = $ current -> format ( 'Y-m-d' ) ; $ user_id = Auth :: user ( ) -> id ; $ member = new Member ( ) ; $ member -> member_no = " # " . $ time ; $ member -> ledgerid = $ request -> ledgerid ; $ member -> name = $ request -> name ; $ member -> mobile = $ request -> phone ; $ member -> father_name = $ request -> father_name ; $ member -> husband_name = $ request -> husband_name ; $ member -> mother_name = $ request -> mothername ; $ member -> occupation = $ request -> income_source ; $ member -> age = $ request -> memberage ; $ member -> gender = $ request -> gender ; $ member -> religion = $ request -> religion ; $ member -> marital_status = $ request -> Maritalstatus ; $ member -> present_address = $ request -> present_address ; $ member -> permanent_address = $ request -> permanent_address ; $ member -> join_date = $ date ; $ member -> status = " 0 " ; $ member -> slag = $ slag ; $ member -> user_id = $ user_id ; $ member -> save ( ) ; $ memberid = $ member -> id ; $ member_nuid = new NidImage ( ) ; $ member_nuid -> member_id = $ memberid ; $ member_nuid -> nuid_no = $ request -> nid_no ; $ nuidimage = $ request -> nid_image ; if ( $ request -> hasFile ( 'nid_image' ) ) { $ 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' ) ) { $ avatarimageFilename = time ( ) . $ ImgName . $ avatarimage -> getClientOriginalExtension ( ) ; Image :: make ( $ avatarimage -> getRealPath ( ) ) -> resize ( 300 , 300 ) -> save ( public_path ( '/Media/Member_Avature/' . $ avatarimageFilename ) ) ; $ member_nuid -> member_image = $ avatarimageFilename ; } $ member_nuid -> save ( ) ; $ saving = new Saving ( ) ; $ saving -> member_id = $ memberid ; $ saving -> savings_no = $ SavingAcno ; $ saving -> opening_date = $ date ; $ saving -> save ( ) ; $ memberaccount = new MemberAccount ( ) ; $ memberaccount -> member_id = $ memberid ; $ memberaccount -> saving_id = $ SavingAcno ; $ memberaccount -> save ( ) ; $ nominess = new Nominee ( ) ; $ nominess -> member_id = $ memberid ; $ 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 created successfully!' , 'alert-type' => 'success' ) ; return back ( ) -> with ( $ notification ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .