Пример #1
0
 public function postEvaluate(Request $request)
 {
     $data = $request->all();
     $user_id = $data['user_id'];
     $evaluation = $data['evaluation'];
     $user = User::where("id", $user_id)->first();
     $event = $this->currentEvent();
     if ($evaluation == "false") {
         $user->delete();
     } else {
         $user->standing = "active";
         $user->save();
         $position = $data['position'];
         if ($position == "Overall Activity Head") {
             $event->oah_id = $user_id;
             $event->save();
         } elseif ($position == "Committee Head") {
             $comm_id = $data['comm_id'];
             $comm = Committee::where("event_id", $event->id)->where("id", $comm_id)->first();
             $head = new Head();
             $head->position = $comm->name . " Head";
             $head->user_id = $user_id;
             $head->comm_id = $comm->id;
             $head->event_id = $event->id;
             $head->save();
         } else {
             $member = new Member();
             $member->user_id = $user_id;
             $member->comm_id = $comm_id;
             $member->save();
         }
     }
     return redirect('/admin');
 }
Пример #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     if (!isset($data['type'])) {
         $data['type'] = 'none';
     } elseif ($data['type'] == 'member') {
         Validator::make($data, ['firstname' => 'required', 'lastname' => 'required']);
         //create user
         $user = User::create(['name' => $data['firstname'] . ' ' . $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type']]);
         $member = new Member();
         $member->user_id = $user->id;
         $member->firstname = $data['firstname'];
         $member->lastname = $data['lastname'];
         if ($member->save()) {
             session()->flash('success', 'Member Profile Created Successfully!');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     } elseif ($data['type'] == 'artist') {
         Validator::make($data, ['firstname' => 'required', 'lastname' => 'required']);
         //create user
         $user = User::create(['name' => $data['firstname'] . ' ' . $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type']]);
         $artist = new Artist();
         $artist->user_id = $user->id;
         $artist->firstname = $data['firstname'];
         $artist->lastname = $data['lastname'];
         if ($artist->save()) {
             session()->flash('success', 'Artist Profile Created Successfully!');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     } elseif ($data['type'] == 'studio') {
         Validator::make($data, ['name' => 'required', 'title' => 'required']);
         //create user
         $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type']]);
         $studio = new Studio();
         $studio->user_id = $user->id;
         $studio->name = $user->name;
         $studio->title = $data['title'];
         if ($studio->save()) {
             session()->flash('success', 'Studio Created Successfully!');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     }
     //dd($data);
     //do your role stuffs here
     //send verification mail to user
     //--------------------------------------------------------------------------------------------------------------
     //$data['verification_code']  = $user->verification_code;
     Mail::send('emails.welcome', $data, function ($message) use($data) {
         $message->from('*****@*****.**', "Tattoo Cultr");
         $message->subject("Welcome to Tattoo Cultr");
         $message->to($data['email']);
     });
     return $user;
 }
Пример #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $image = $request->file("logo");
     $member = new Member();
     $member->fill($request->except('logo'));
     $member->logo = self::upload_pic($image);
     $member->save();
     return redirect()->route('members.links', $member->id);
 }
Пример #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @Response(201)
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|unique:members,email|regex:/[a-zA-Z]{2,3}\\d{4}/']);
     $member = new Member();
     $member->first_name = $request->input('first_name');
     $member->last_name = $request->input('last_name');
     $member->email = $request->input('email');
     $member->save();
     return new JsonResponse($member, Response::HTTP_CREATED);
 }
 public function store(Request $request)
 {
     $this->validate($request, ['mm_full_name' => 'required|max:225', 'mm_nick_name' => 'required|max:225', 'mm_nohp' => 'required|max:15', 'mm_notelp' => 'required|max:15', 'mm_address' => 'required', 'mm_hoby' => 'required']);
     $member = new Member();
     $member->mm_full_name = $request->mm_full_name;
     $member->mm_nick_name = $request->mm_nick_name;
     $member->mm_nohp = $request->mm_nohp;
     $member->mm_notelp = $request->mm_notelp;
     $member->mm_address = $request->mm_address;
     $member->mm_hoby = $request->mm_hoby;
     $member->save();
     return redirect('members');
 }
Пример #6
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $member = new Member();
     $member->fname = $data['firstname'];
     $member->lname = $data['lastname'];
     $member->email = $data['email'];
     $member->bday = $data['birthday'];
     $member->gender = $data['gender'];
     $member->mobile = $data['mobile'];
     $member->save();
     $inserted_id = $member->id;
     return User::create(['email' => $data['email'], 'password' => bcrypt($data['password']), 'indicator_id' => '5', 'login_id' => $inserted_id]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $Member = new Member();
     $Member->name = $request->get('name');
     $Member->email = $request->get('email');
     $Member->phone = $request->get('phone');
     $Member->country = $request->get('country');
     $Member->uid = $request->user()->id;
     $Member->save();
     $members = Member::all();
     $request->session()->flash('flash_message', "Member added succesfully");
     return redirect()->back();
 }
Пример #8
0
 public function postEquipe(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required', 'photo' => 'required', 'gender' => 'required', 'cargo-new' => 'required', 'area-new' => 'required']);
     $membro = new Member();
     $membro->name = Input::get('name');
     $membro->email = Input::get('email');
     $membro->photo = Input::get('photo');
     $membro->gender = Input::get('gender');
     $membro->cargo = Input::get('cargo-new');
     $membro->diretoria = Input::get('area-new');
     $membro->save();
     $equipe = Member::all()->sortBy("name");
     return redirect('/editar_equipe')->with('equipe', $equipe);
 }
Пример #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['hasKeys' => array('regex:/^(1|0|true|false)$/i'), 'name' => array('regex:/^[\\d\\w\\.][\\d\\w\\s\\.]*[\\d\\w\\.]$/'), 'active' => array('regex:/^(1|0|true|false)$/')]);
     if ($validator->fails()) {
         return response()->json(["error" => "validator failed", "cause" => $validator->failed()], 400);
     } else {
         $member = new Member();
         $member->hasKeys = $request->hasKeys;
         $member->name = $request->name;
         $member->active = $request->active;
         $member->save();
         return response()->json($member, 201);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $rules = ["name" => "required|min:3", "email" => "required|email", "blog" => "url", "github" => "", "twitter" => "", "group" => "exists:groups,id", "g-recaptcha-response" => "required|captcha"];
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return Redirect::route("community.create")->withErrors($validator)->withInput();
     }
     $member = new Member();
     $member->name = $request->input("name");
     $member->email = $request->input("email");
     $member->blog = $request->input("blog");
     $member->github = $request->input("github");
     $member->twitter = $request->input("twitter");
     $member->group_id = $request->input("group");
     $member->save();
     return Redirect::route("community.index")->with("success", "Başarıyla topluluğa katıldınız!");
 }
Пример #11
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->registrar->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $this->auth->login($this->registrar->create($request->all()));
     $member = new Member();
     $member->first_name = $request->first_name;
     $member->last_name = $request->last_name;
     $member->save();
     $mail = new Mail();
     $mail->mail = $request->email;
     $mail->code = rand(1000000, 9999999);
     $mail->save();
     return redirect($this->redirectPath());
 }
Пример #12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $appli = MemApplicant::findOrFail($request::get('id'));
     $appli->accepted = $request::get('accept');
     //dd($appli->accepted);
     $appli->save();
     if ($appli->accepted == 'true') {
         $mem = new Member();
         $mem->lName = $appli->lName;
         $mem->fName = $appli->fName;
         $mem->mName = $appli->mName;
         $mem->gender = $appli->gender;
         $mem->memDate = Carbon::now();
         $mem->addr = $appli->addr;
         $mem->bDay = $appli->bDay;
         $mem->religion = $appli->religion;
         $mem->civilStatus = $appli->civilStatus;
         $mem->spouse = $appli->spouse;
         $mem->highestEd = $appli->highestEd;
         $mem->occupation = $appli->occupation;
         $mem->beneficiary = $appli->beneficiary;
         $mem->relToMem = $appli->relToMem;
         $mem->contact = $appli->contact;
         $mem->initShare = $appli->initShare;
         $mem->amntShare = $appli->amntShare;
         $mem->initCBU = $appli->initCBU;
         $mem->landArea = $appli->landArea;
         $mem->credLine = $appli->credLine;
         $mem->municipality = $appli->municipality;
         $mem->barangay = $appli->barangay;
         $mem->ownType = $appli->ownType;
         //$mem->termination= $appli->termination;
         $mem->status = $request::get('status');
         $mem->save();
         $us = new User();
         $us->email = $appli->email;
         $us->member_id = $mem->id;
         $us->password = bcrypt('regular');
         //to randomize
         $us->save();
     }
     $appli->delete();
     flash()->success("Success!");
     return redirect('/admin');
 }
 public function store(MemberRequest $request)
 {
     $input = $request->all();
     $member = new Member();
     $member->name = $input['name'];
     $member->email = $input['email'];
     $member->phone = $input['phone'];
     if ($request->file()) {
         $image = $request->file('image');
         $filename = $request->file('image')->getClientOriginalName();
         $path = public_path('img/' . $filename);
         $size = '200,200';
         Image::make($image->getRealPath())->resize(intval($size), null, function ($contstraint) {
             $contstraint->aspectRatio();
         })->save($path);
         $member->image = 'img/' . $filename;
     }
     $member->save();
     return redirect('member');
 }
Пример #14
0
 public function store(MemberCreateRequest $request)
 {
     if ($request->file('photo')) {
         $file = $request->file('photo');
         $name = 'fotogym_' . time() . '.' . $file->getClientOriginalExtension();
         $path = public_path() . '/images/members/';
         $file->move($path, $name);
     }
     $member = new Member($request->all());
     $member->save();
     $image = new Image();
     if (isset($name)) {
         $image->name = $name;
     } else {
         $image->name = 'fotogym_placeholder.png';
     }
     $image->member()->associate($member);
     $image->save();
     Flash::success("¡Se ha registrado a " . $member->first_name . " de manera exitosa!");
     return redirect()->route('medicalrecord.create', $image->member_id);
 }
 /**
  * Display the complete profile form
  *
  * @return View
  */
 public function completeProfileMember()
 {
     $user = Auth::user();
     if ($user->type == "none") {
         $member = new Member();
         $member->user_id = $user->id;
         $member->firstname = $user->name;
         $member->lastname = '';
         if ($member->save()) {
             $user->type = 'member';
             $user->save();
             session()->flash('success', 'Member Profile Created Successfully!');
         }
     }
     if ($user->type == 'artist') {
         return redirect('complete-profile-artist');
     }
     if (!$user->social) {
         $user->avatar = url('uploads/images/small/' . $user->avatar);
     }
     return view('pages.completeProfileMember', ['user' => $user]);
 }
Пример #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->only('fname', 'email', 'mname', 'lname', 'address', 'identity', 'nationality', 'dob', 'ban', 'cNumber', 'mNumber');
     //return $data;
     $member = new Member();
     $member->fname = $data['fname'];
     $member->mname = $data['mname'];
     $member->lname = $data['lname'];
     $member->email = $data['email'];
     $member->address = $data['address'];
     $member->identity = $data['identity'];
     $member->nationality = $data['nationality'];
     $member->dob = $data['dob'];
     $member->ban = $data['ban'];
     $member->cNumber = $data['cNumber'];
     $member->mNumber = $data['mNumber'];
     $member->status = "0";
     $member->mtype = "0";
     $member->password = Hash::make('password');
     $member->save();
     return $member->id;
 }
Пример #17
0
 /**
  * Save a new member
  *
  * @param MemberRequest $request
  */
 private function createMember(MemberRequest $request)
 {
     // Find order of the new member based on district (to add the member at the end of their district)
     $district = District::findOrFail($request->input('district'));
     $order = $district->members->count() + 1;
     // Make a new member and save it
     $member = new Member();
     $member->first_name = $request->input('first_name');
     $member->last_name = $request->input('last_name');
     $member->district_id = $request->input('district');
     $member->order = $order;
     $member->save();
     // Get selected members and save them (if there are any)
     $groups = $request->input('group_list');
     if (count($groups) > 0) {
         $this->syncGroups($member, $groups);
     }
 }
Пример #18
0
 public function addMember(Request $request)
 {
     $data = $request->only('fname', 'email', 'mname', 'lname', 'address', 'identity', 'nationality', 'dob', 'ban', 'cNumber', 'mNumber');
     try {
         $member = new Member();
         if ($data['fname']) {
             $member->fname = $data['fname'];
         }
         if ($data['mname']) {
             $member->mname = $data['mname'];
         }
         if ($data['lname']) {
             $member->lname = $data['lname'];
         }
         $member->email = $data['email'];
         $member->address = $data['address'];
         $member->identity = $data['identity'];
         $member->nationality = $data['nationality'];
         $member->dob = $data['dob'];
         $member->ban = $data['ban'];
         $member->cNumber = $data['cNumber'];
         $member->mNumber = $data['mNumber'];
         $member->status = "0";
         $member->mtype = $request['mtype'];
         $member->agentId = 0;
         if (isset($request['agent']) && ($agent = Member::where('username', '=', $request['agent'])->first())) {
             $member->agentId = $agent->id;
         }
         $member->username = $this->createUsername(sprintf("%02d", $member->agentId) . sprintf("%02d", $request['mtype']));
         $member->password = Hash::make($member->username);
         if ($member->save()) {
             $returnData = array('status' => 'ok', 'message' => 'member created', 'member' => $member, 'code' => 200);
             return Response::json($returnData, 200);
         } else {
             $returnData = array('status' => 'fail', 'message' => 'member not created', 'code' => 500);
             return Response::json($returnData, 200);
         }
     } catch (\Exception $e) {
         return $e->getMessage();
     }
 }
Пример #19
0
 public function postCreateMember()
 {
     $user = $this->auth->user();
     $member_id = Input::get("member_id");
     $firstname = Input::get("firstname");
     $lastname = Input::get("lastname");
     $gender = Input::get("gender");
     $birthday = Input::get("birthday");
     $address = Input::get("address");
     $start_date = Input::get("start_date");
     $end_date = Input::get("end_date");
     $balance = Input::get("balance");
     $level = Input::get("level");
     $email = Input::get("email");
     $phone = Input::get("phone");
     $member = Member::where('member_id', '=', $member_id)->get()->first();
     if (!$member) {
         //register in the system
         $member = new Member();
         $member->member_id = $member_id;
         $member->first_name = $firstname;
         $member->last_name = $lastname;
         $member->gender = $gender;
         $member->birthday = date('Y-m-d', strtotime($birthday));
         $member->address = $address;
         $member->start_date = date('Y-m-d', strtotime($start_date));
         $member->end_date = date('Y-m-d', strtotime($end_date));
         $member->balance = $balance;
         $member->level = $level;
         $member->email = $email;
         $member->phone = $phone;
         $saved = $member->save();
     } else {
         $message = trans("locale.member_already_exists");
         return view('home')->with("message", $message);
     }
     return redirect::to('home');
 }
Пример #20
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CreateMemberRequest $request)
 {
     $input = Request::all();
     $member = new Member();
     $member->id_number = $input['id_number'];
     $member->first_name = $input['first_name'];
     $member->last_name = $input['last_name'];
     $member->year = $input['year'];
     $member->course = $input['course'];
     $member->email = $input['email'];
     $member->birthday = $input['birthday'];
     $member->status = $input['status'];
     $member->department = $input['department'];
     $member->save();
     return redirect()->action('MembersController@show', $member->id);
 }
Пример #21
0
 public function PostHireMember($id, $mc, $stores, $data)
 {
     $now = date('Y-m-d');
     $db = new Member();
     $db->id_stores = $stores;
     $db->id_users = $data;
     $db->start = $now;
     $db->id_member_cats = $mc;
     $db->status = 1;
     $db->save();
     $db_em = Employee::find($data);
     $db_em->status = 1;
     $db_em->save();
     Alert::success('Sukses menambah member')->persistent("Close");
     return redirect('project/view/' . $id);
 }
Пример #22
0
 private function storeStudentIndividual()
 {
     $var = DB::transaction(function ($connection) {
         $membership_period = Input::get('membership-period');
         $salutation = Input::get('salutation');
         $fname = Input::get('fname');
         $mname = Input::get('mname');
         $lname = Input::get('lname');
         $card_name = Input::get('card_name');
         $dob = Input::get('dob');
         $gender = Input::get('gender');
         $country = Input::get('country');
         $state = Input::get('state');
         $address = Input::get('address');
         $city = Input::get('city');
         $pincode = Input::get('pincode');
         $stud_branch = Input::get('stud_branch');
         $college = Input::get('college');
         $course = Input::get('course');
         $cbranch = Input::get('cbranch');
         $cduration = Input::get('cduration');
         $email1 = Input::get('email1');
         $email2 = Input::get('email2');
         $std = Input::get('std');
         $phone = Input::get('phone');
         $country_code = Input::get('country-code');
         $mobile = Input::get('mobile');
         $paymentMode = Input::get('paymentMode');
         $tno = Input::get('tno');
         $drawn = Input::get('drawn');
         $bank = Input::get('bank');
         $branch = Input::get('branch');
         $paymentReciept = Input::file('paymentReciept');
         $amountPaid = Input::get('amountPaid');
         $student_branch = AcademicMember::Where('is_student_branch', $stud_branch)->first();
         $chapter = $student_branch->institution->member->csi_chapter_id;
         $member = new Member();
         $member->membership_id = 2;
         // individual member
         $membership_type = 3;
         // student member
         $member->csi_chapter_id = $chapter;
         $member->email = $email1;
         $member->email_extra = $email2;
         $member->password = bcrypt('1234');
         $member->save();
         $member->id;
         $filename = $member->id . '.';
         $filename .= $paymentReciept->getClientOriginalExtension();
         Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => $country, 'state_code' => $state, 'address_line_1' => $address, 'city' => $city, 'pincode' => $pincode]);
         Phone::create(['member_id' => $member->id, 'std_code' => $std, 'landline' => $phone, 'country_code' => $country_code, 'mobile' => $mobile]);
         $paymentReciept->move(storage_path('uploads/payment_proofs'), $filename);
         $individual = Individual::create(['member_id' => $member->id, 'membership_type_id' => $membership_type, 'salutation_id' => $salutation, 'first_name' => $fname, 'middle_name' => $mname, 'last_name' => $lname, 'card_name' => $card_name, 'gender' => $gender, 'dob' => $dob]);
         $student_details = StudentMember::create(['id' => $individual->id, 'student_branch_id' => $student_branch->id, 'college_name' => $college, 'course_name' => $course, 'course_branch' => $cbranch, 'course_duration' => $cduration]);
         // 2nd arg is currency.. needs to be queried to put here
         $head = PaymentHead::getHead($membership_period, 1)->first();
         $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]);
         $narration = Narration::create(['payer_id' => $member->id, 'mode' => $paymentMode, 'transaction_number' => $tno, 'bank' => $bank, 'branch' => $branch, 'date_of_payment' => $drawn, 'drafted_amount' => $head->amount, 'paid_amount' => $amountPaid, 'proof' => $filename]);
         $journal = Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id]);
         if (!is_null($member->id) && $member->id > 0) {
             $user = $member;
         }
         return $member;
     });
     return $var;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['full_name' => 'required|string']);
     $duplicate = Member::where('full_name', $request->full_name)->where('department_id', Auth::user()->department_id)->first();
     if ($duplicate) {
         return response()->json(true);
     }
     $member = new Member();
     $member->full_name = $request->full_name;
     // $member->date_hired = $request->date_hired;
     $member->department_id = Auth::user()->department_id;
     // get the difference of months from date hired to present
     // $tenure = date_diff(Carbon::today(), date_create($request->date_hired))->format("%m");
     // $member->experience = $tenure < 3 ? 'Beginner' : (($tenure > 3 && $tenure < 6) ? 'Moderately Experienced' : 'Experienced');
     $member->save();
     return $member->id;
 }
Пример #24
0
 public function PostHireMember($id, $mc, $stores, $data)
 {
     // Start Check Authorization
     /**
      * 1. FullAccess - 1
      * 2. HRD - 3
      * 3. Creator - 5
      * 4. Handler - 7
      */
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 7 or $authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $id);
     }
     // End Check Authorization
     $now = date('Y-m-d');
     $db = new Member();
     $db->id_stores = $stores;
     $db->id_users = $data;
     $db->start = $now;
     $db->id_member_cats = $mc;
     $db->status = 1;
     $db->save();
     $db_em = Employee::find($data);
     $db_em->status = 1;
     $db_em->save();
     Alert::success('Sukses menambah member')->persistent("Close");
     return redirect('project/view/' . $id);
 }
Пример #25
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $data['email_verification_code'] = str_random(55);
     $data['lastname'] = '';
     if (!isset($data['type'])) {
         $data['type'] = 'none';
     } elseif ($data['type'] == 'member') {
         Validator::make($data, ['firstname' => 'required', 'gender' => 'required']);
         if ($data['gender'] == "female") {
             $data['avatar'] = 'avatar-female.jpg';
         } else {
             $data['avatar'] = 'avatar.jpg';
         }
         //create user
         $user = User::create(['name' => $data['firstname'] . ' ' . $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type'], 'avatar' => $data['avatar'], 'email_verification_code' => $data['email_verification_code']]);
         $member = new Member();
         $member->user_id = $user->id;
         $member->firstname = $data['firstname'];
         $member->lastname = '';
         $member->gender = $data['gender'];
         $data['name'] = $data['firstname'] . ' ' . $data['lastname'];
         if ($member->save()) {
             session()->flash('success', 'Welcome ' . $data['firstname'] . '! Please continue connecting with artists and collecting tattoos');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     } elseif ($data['type'] == 'artist') {
         Validator::make($data, ['firstname' => 'required']);
         $data['gender'] = 'male';
         //male by default
         if ($data['gender'] == "female") {
             $data['avatar'] = 'avatar-female.jpg';
         } else {
             $data['avatar'] = 'avatar.jpg';
         }
         //create user
         $user = User::create(['name' => $data['firstname'] . ' ' . $data['lastname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type'], 'avatar' => $data['avatar'], 'email_verification_code' => $data['email_verification_code']]);
         $artist = new Artist();
         $artist->user_id = $user->id;
         $artist->firstname = $data['firstname'];
         $artist->lastname = $data['lastname'];
         $artist->gender = $data['gender'];
         $data['name'] = $data['firstname'] . ' ' . $data['lastname'];
         if ($artist->save()) {
             session()->flash('success', 'Welcome ' . $data['firstname'] . '! Lets start with building your profile.');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     } elseif ($data['type'] == 'studio') {
         Validator::make($data, ['name' => 'required']);
         //create user
         $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'contact' => $data['contact'], 'type' => $data['type'], 'email_verification_code' => $data['email_verification_code']]);
         $studio = new Studio();
         $studio->user_id = $user->id;
         $studio->name = $user->name;
         $studio->title = '';
         if ($studio->save()) {
             session()->flash('success', 'Welcome ' . $data['name'] . '! Lets start with building your profile.');
         } else {
             $user->delete();
             session()->flash('error', 'Error! Please try again..');
         }
     }
     if ($slugExit = User::where('slug', str_slug($data['name'], "."))->first()) {
         $data['slug'] = str_slug($data['name'] . $user->id, ".");
         $user->slug = $data['slug'];
     } else {
         $data['slug'] = str_slug($data['name'], ".");
         $user->slug = $data['slug'];
     }
     $user->save();
     //send verification mail to user
     Mail::send('emails.welcome', $data, function ($message) use($data) {
         $message->from('*****@*****.**', "Tattoo Cultr");
         $message->subject("Welcome to Tattoo Cultr");
         $message->to($data['email']);
     });
     Mail::send('emails.admin_notification_signup', $data, function ($message) use($data) {
         $message->from('*****@*****.**', "Tattoo Cultr");
         $message->subject("New User Signup");
         $message->to(env('ADMIN_EMAIL'));
     });
     return $user;
 }