public function edit(Request $request)
 {
     $rules = array('fullname' => 'required', 'address' => 'required', 'zipcode_id' => 'required');
     $validator = \Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => 'ข้อมูลผิดพลาด', 'message' => $validator->messages()->all()));
     }
     $user = \Auth::user();
     if ($user == null) {
         return Response::json(array('result' => false, 'data' => 'can not define user.'));
     }
     $member = Member::where('id', $user->id)->first();
     //var_dump($member);
     $member->fullname = $request->input('fullname');
     $member->address = $request->input('address');
     $member->district_id = $request->input('district_id');
     $member->amphur_id = $request->input('amphur_id');
     $member->province_id = $request->input('province_id');
     $member->zipcode_id = $request->input('zipcode_id');
     if ($member->save()) {
         return Response::json(array('result' => true, 'data' => 'บันทึกข้อมูลเสร็จเรียบร้อย'));
     } else {
         return Response::json(array('result' => false, 'data' => 'เกิดข้อผิดพลาด'));
     }
 }
Пример #2
0
 /**
  * Fonction permettant de tester la
  * suppression d'un membre d'un projet
  *
  * @return void
  */
 public function testDeleteMember()
 {
     Member::create(["project_id" => 2, "Developer_id" => 2]);
     $cnt = new MemberController();
     $cnt->remove(2, 2);
     $this->assertEquals(null, Member::where("project_id", 2)->where("Developer_id", 2)->get()->first());
 }
Пример #3
0
 public function showMember(Request $r)
 {
     $member = Member::where("id", $r->input('id'))->get();
     $hc = new HomeController();
     $vars = $hc->getVars();
     return view('member', ['member' => $member[0], "lang" => "fa", "vars" => $vars]);
 }
Пример #4
0
 public function projectList()
 {
     $projects_member_id = Member::where("Developer_id", auth()->User()->id)->get()->pluck("project_id");
     $project_owner_id = Project::where("developer_id", auth()->User()->id)->get()->pluck("id");
     $projects_id = array_merge($projects_member_id->toArray(), $project_owner_id->toArray());
     $project = Project::whereIn("id", $projects_id)->get();
     $developer = DB::table('Developer')->get();
     return view("project.list")->with('project', $project)->with('developer', $developer);
 }
 public function filter()
 {
     $input = Request::all();
     $filter = $input['filter'];
     $members = Member::where('department', $filter)->get();
     if ($members == "[]") {
         return redirect()->action('TambayPointsController@index');
     }
     return view('tambay_points.index', compact('members'));
 }
Пример #6
0
 public function findMemberByDocument(Request $request)
 {
     $member = Member::where('document', $request->documento)->first();
     //dd($member);
     if ($member == null) {
         Flash::warning("No existe nungun miembro con el documento " . $request->documento . " registrado");
         return redirect()->route('admin.member.index');
     } else {
         return redirect()->route('admin.member.show', ['member' => $member]);
     }
 }
 public function memberLogin(\Illuminate\Http\Request $request)
 {
     $member = Member::where('email', $request->email)->where('password', $request->password)->get();
     //return $member[0]->id;
     if (!$member->isEmpty()) {
         //$halls=Hall::where('member_id',$member[0]->id)
         $hall = Hall::where('member_id', $member[0]->id)->get();
         $hall = $hall[0];
         //dd($hall);
         return Redirect('members/settings')->with('hall', $hall);
     }
     return "Login Failed";
 }
 public function update(Request $request)
 {
     $validator = Validator::make($request->all(), ['id' => 'required', 'point' => 'integer']);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => 'Input is valid.'));
     }
     $member = Member::where('id', $request->input('id'))->get()->first();
     if ($member) {
         $member->fullname = $request->input('fullname');
         $member->address = $request->input('address');
         $member->phone = $request->input('phone');
         $member->province_id = $request->input('province_id');
         $member->amphur_id = $request->input('amphur_id');
         $member->district_id = $request->input('district_id');
         $member->zipcode_id = $request->input('zipcode_id');
         $member->point = $request->input('point');
         $member->save();
         return Response::json(array('result' => true, 'data' => 'Update ' . $member->email . ' success.'));
     }
     return Response::json(array('result' => false, 'data' => 'Update ' . $member->email . ' fail.', 'member' => $member));
 }
Пример #9
0
 /**
  * Remove the specified resource from storage.
  * Defaults to a soft delete; add ?remove=permanent to do hard delete
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $id)
 {
     // remove -- [ discharge | permanent ]
     $removeMode = $request->query('remove', 'discharge');
     $deleted = 0;
     try {
         if ($removeMode == 'permanent') {
             $deletionMember = Member::where('regt_num', $id)->withTrashed()->firstOrFail();
             // Todo: future permissions check
             $permissionsCheck = true;
             if ($permissionsCheck || $deletionMember->is_active == '0') {
                 // Allow anybody to delete inactive records
                 $deletionMember->postings()->forceDelete();
                 $deletionMember->forceDelete();
                 // this returns void
                 $deleted = true;
                 // we just presume it worked, since we deleted the postings already
             } else {
                 throw new \Exception('You don\'t have permission to permanently delete this record', ResponseCodes::ERR_PERM_NOPE);
             }
         } else {
             // Soft delete -- read overrides from context
             $deleted = Member::findOrFail($id)->delete();
         }
         return response()->json(['success' => $deleted, 'deletionMode' => $removeMode]);
     } catch (\Exception $ex) {
         if (!$deleted) {
             return response()->json(['error' => ['code' => ResponseCodes::ERR_DELETION, 'deletionResult' => print_r($deleted, true), 'reason' => "Could not delete this record {$id}"]], 401);
         } else {
             return response()->json(['error' => ['code' => $ex->getCode(), 'reason' => $ex->getMessage()]], 403);
         }
     }
 }
Пример #10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id The id of the member to delete
  * @return Response
  */
 public function destroy($id)
 {
     // Find member
     $member = Member::findOrFail($id);
     // Find members of the same perifereia with order bigger than this member's and fix them
     $membersToFix = Member::where('district_id', '=', $member->district->id)->where('order', '>', $member->order)->get();
     foreach ($membersToFix as $m) {
         $m->order = $m->order - 1;
         $m->save();
     }
     // Delete the member
     $member->delete();
     // Redirect
     Session::flash('message', 'Ο/Η βουλευτής διαγράφηκε με επιτυχία!');
     return Redirect::to('members');
 }
 public function postResetPassword(){
     $user = Member::where('username',$this->request->input('username'))->first();
     $validator = Validator::make($this->request->all(), [
         'username'    =>'required|min:10|max:20|exists:member,username',
         'new_password'=>'required|min:10|max:20',
         'secretanswer'=>'required|min:1|max:100|exists:member,secretanswer,username,'.$user['username']
     ]);
     if ($validator->fails()){
         return view('resetpassword')->with('cart',$this->getCart())
                                      ->with('username',$user->username)
                                      ->with('secretquestion',$user->secretquestion)
                                      ->with('ferrors',$validator->errors());
     }else{
     $user = Member::where('username',$this->request->input('username'))->first();
     $user->password = $this->request->input('new_password');
     $user->save();
         return view('login')->with('cart',$this->getCart())
                             ->with('success','Your account password has been successfully reset.');
     }
 }
Пример #12
0
 public function index($memberId)
 {
     $memberPostingRecords = Member::where('regt_num', $memberId)->withTrashed()->get();
     return response()->json($memberPostingRecords->postings->toArray());
 }
 public function block($id)
 {
     $ret = Member::where('id', $id)->first();
     if ($ret->status == 1) {
         $update = \DB::table('members')->where('id', $id)->update(['status' => 0]);
         Session::flash('blockmessage', 'Member has been blocked successfully');
     } else {
         $update = \DB::table('members')->where('id', $id)->update(['status' => 1]);
         Session::flash('unblockmessage', 'Member has been unblocked successfully');
     }
     Session::flash('memberid', $ret->type);
     return \Redirect::to('member/show');
 }
 public function forUser(User $user)
 {
     return Member::where('user_id', $user->id)->orderBy('created_at', 'desc')->get();
 }
Пример #15
0
 /**
  * Change Account Basic details
  *
  * @param  Request  $request
  * @return Response
  */
 public function changeProfile(Request $request)
 {
     $this->validate($request, ['current_password' => 'required|min:6']);
     $user = Auth::user();
     if ($user->type == 'studio') {
         $this->validate($request, ['name' => 'required']);
     } else {
         $this->validate($request, ['firstname' => 'required']);
     }
     if ($user->email != $request->input('email')) {
         $this->validate($request, ['email' => 'required|email|max:255|unique:users']);
     }
     if ($user->contact != $request->input('contact')) {
         $this->validate($request, ['contact' => 'required|digits:10']);
     }
     if (Hash::check($request->input('current_password'), $user->password)) {
         if ($user->type == 'artist') {
             $artist = Artist::where('user_id', $user->id)->first();
             $artist->firstname = $request->input('firstname');
             $artist->lastname = '';
             $artist->save();
             $user->name = $request->input('firstname');
         } elseif ($user->type == 'member') {
             $member = Member::where('user_id', $user->id)->first();
             $member->firstname = $request->input('firstname');
             $member->lastname = '';
             $member->save();
             $user->name = $request->input('firstname');
         } elseif ($user->type == 'studio') {
             $studio = Studio::where('user_id', $user->id)->first();
             $studio->title = '';
             $studio->name = $request->input('name');
             $studio->save();
             $user->name = $request->input('name');
         }
         $user->email = $request->input('email');
         $user->contact = $request->input('contact');
         $user->save();
         return redirect('profile#edit')->with('success', 'Profile changed successfully!');
     }
     return redirect('profile#edit')->with('warning', 'Wrong Password!');
 }
Пример #16
0
 public function getId($id)
 {
     $users = User::all();
     $user = $this->getUser();
     $curr_event = Event::where('id', $id)->first();
     $all_comm = Committee::all();
     $committees = Committee::where('event_id', $curr_event->id)->get();
     $comm_array = Committee::where('event_id', $curr_event->id)->get(array('id'))->toArray();
     $events = Event::all();
     $tasks = Task::where('assigned_to', $user['id'])->whereIn('comm_id', $comm_array)->get();
     //tasks assigned to current user
     $all_tasks = Task::all();
     $categories = array('Pending', 'In-progress', 'Delayed', 'Finished');
     $comments = Comment::all();
     //get current event id
     $curr_event_id = $curr_event->id;
     //check if current user is upper head
     //get all heads of current event
     $heads = Head::where('event_id', $curr_event_id)->where('user_id', $user->id)->get();
     //get all comm_id(as array) in the current event where current user is a head
     $heads_comm = Head::where('event_id', $curr_event_id)->where('user_id', $user['id'])->get(array('comm_id'))->toArray();
     //members of committee
     $mem = Member::whereIn('comm_id', $heads_comm)->get(array('user_id'))->toArray();
     $members = User::whereIn('id', $mem)->get();
     //get all committees in the current event where current user is a head
     $head_committees = Committee::whereIn('id', $heads_comm)->get();
     //current user is a head
     $heads_comm = Head::where('user_id', $user['id'])->get();
     //committees where current user is a member
     $mem_comm = Member::where('user_id', $user['id'])->get();
     $url = "pages/profile";
     //check if curret user is admin
     if ($user->id == 1) {
         return redirect('/admin/');
     }
     //check if current user is OAH
     if ($curr_event->oah_id == $user->id) {
         $url = "pages/oah";
     }
     //return heads page if user is lower head
     if ($heads != "[]") {
         $url = "pages/heads";
     }
     if ($user->standing == "unconfirmed") {
         $url = "pages/oops";
     }
     echo $url;
     return view($url, compact('users', 'user', 'events', 'curr_event', 'all_comm', 'committees', 'tasks', 'all_tasks', 'categories', 'comments', 'head_committees', 'heads_comm', 'mem_comm', 'members'));
 }
 public function postUserIndex(Request $request)
 {
     $validator = Validator::make($request->all(), ['username' => 'required|exists:mysql_old.member,id']);
     if ($validator->fails()) {
         return response()->json(['success' => false, 'error_message' => $validator->errors()->getMessages()]);
     }
     $userid = $request->input('username');
     $uname = Member::where('id', '=', $userid)->first()->uname;
     $set1 = \DB::connection('mysql_old')->table('data')->where('userid', $userid)->where('heartrate', '!=', 0)->orderBy('time', 'DESC')->select(['heartrate', 'spo2'])->first();
     $set2 = \DB::connection('mysql_old')->table('data')->where('userid', $userid)->orderBy('time', 'DESC')->select(['id', 'activity', 'sleep_total_time'])->first();
     $set3 = \DB::connection('mysql_old')->table('data_warn_save')->where('userid', $userid)->where('type', '!=', 5)->orderBy('id', 'DESC')->first();
     $relative = Relative::where('mid', $userid)->where('main', 1)->first();
     $sleep = $set2 ? $set2->sleep_total_time : 0;
     $recent_warn = [];
     for ($i = 1; $i <= 5; $i++) {
         $warn = \DB::connection('mysql_old')->table('data_warn_save')->where('userid', $userid)->where('type', '=', $i)->orderBy('id', 'DESC')->first();
         $recent_warn[] = $warn;
     }
     return response()->json(['success' => true, 'result' => ['bloodOxygen' => $set1 ? $set1->spo2 : null, 'heartRate' => $set1 ? $set1->heartrate : null, 'activity' => $set2 ? $set2->activity : null, 'sleep' => $sleep >= 360 ? '良好' : '差', 'recent_warn' => $recent_warn, 'uname' => $uname, 'lifeWarning' => null, 'ecg' => null, 'emotion' => null, 'temperature' => null]]);
 }
Пример #18
0
 public function postMultipleCreate(Request $request)
 {
     $excel = $request->file('watch');
     $target = $excel->move(storage_path(), 'test.xslt');
     \Excel::load($target, function ($reader) {
         $array = $reader->get()->toArray();
         $result = [];
         foreach ($array as $item) {
             if ($item[0]) {
                 $result[] = $item[0];
             }
         }
         foreach ($result as $item) {
             if ($member = Member::where('pid', intval($item))->first()) {
                 $member->fid = \Auth::user()->id;
                 $member->uname = \Auth::user()->contact_name;
                 $relative = Relative::where('mid', $member->id)->where('main', 1)->first();
                 if (!$relative) {
                     $relative = new Relative();
                 }
                 $relative->name = \Auth::user()->contact_name;
                 $relative->phone = \Auth::user()->contact_phone;
                 $relative->mid = $member->id;
                 $relative->main = 1;
                 $relative->save();
                 $member->save();
             }
         }
     });
     if (\Auth::user()->user_type == 0) {
         $items = Member::paginate(10);
     } else {
         $items = Member::where('fid', '=', \Auth::user()->id)->paginate(10);
     }
     return view('watch.index')->with(['success' => true, 'items' => $items]);
 }
Пример #19
0
 /**
  * Display User Profile Page
  *
  * @return View
  */
 public function profile()
 {
     $user = Auth::user();
     //if not an image url from facebook
     if (filter_var($user->avatar, FILTER_VALIDATE_URL) === FALSE) {
         $user->avatar = url('uploads/images/thumbnail/' . $user->avatar);
     }
     if (!$user->verified) {
         session()->flash('warning', 'Please verify your email address!!');
     }
     //if user is artist, load artist profile view
     if ($user->type == 'artist') {
         $artist = Artist::where('user_id', $user->id)->first();
         $artist->cover = url('uploads/images/large/' . $artist->cover);
         if (filter_var($artist->user->avatar, FILTER_VALIDATE_URL) === FALSE) {
             $artist->user->avatar = url('uploads/images/thumbnail/' . $artist->user->avatar);
         }
         $isArtistProfile = true;
         return view('pages.artist', ['user' => $user, 'artist' => $artist, 'isArtistProfile' => $isArtistProfile]);
     } elseif ($user->type == 'studio') {
         $studio = Studio::where('user_id', $user->id)->first();
         $studio->cover = url('uploads/images/large/' . $studio->cover);
         return view('pages.studio', ['user' => $user, 'studio' => $studio]);
     } elseif ($user->type == 'member') {
         $member = Member::where('user_id', $user->id)->first();
         return view('pages.member', ['user' => $user, 'member' => $member]);
     } else {
         return redirect('complete-profile')->flash('success', 'Welcome. Please complete your profile..');
     }
     return redirect('/');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Member::where('id', $id)->delete();
 }
 public function update(Request $request)
 {
     $validator = Validator::make($request->all(), ['orders_number' => 'required', 'status' => 'required']);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => 'Some parameter not found.'));
     }
     if ($request->input('status') != 2 && $request->input('status') != 3) {
         return Response::json(array('result' => false, 'data' => 'Status is wrong.'));
     }
     $order = Orders::where('orders_number', $request->input('orders_number'))->get()->first();
     if (!$order) {
         return Response::json(array('result' => false, 'data' => 'Order is empty.'));
     }
     $order->post_number = $request->input('post_number') == "" ? null : $request->input('post_number');
     $order->status = $request->input('status');
     $order->updated_at = Carbon::now('Asia/Bangkok');
     //get point
     $a = 0;
     $b = false;
     $member = Member::where('id', $order->members_id)->first();
     //var_dump($member);
     if ($member != null) {
         $point = 0;
         $n = 0;
         $pointlist = DB::table('v_products_vol')->where('orders_number', $request->input('orders_number'))->get();
         foreach ($pointlist as $key => $value) {
             # code...
             $point += $value->point * $value->product_vol_qty;
             $n += $value->product_vol_qty;
         }
         $sum_point = $member->point + $point + ($n - 1);
         $member->point = $sum_point;
         $member->save();
     }
     if ($order->save()) {
         return Response::json(array('result' => true, 'data' => $order, 'message' => 'Update id ' . $order->orders_number . ' updated.', 'a' => $a, 'b' => $b, 'member' => $member));
     }
     return Response::json(array('result' => false, 'message' => 'Update has been error.'));
 }
Пример #22
0
 /**
  * Display the edit profile page
  * @param  int  $id
  * @return Response
  */
 public function memberEdit()
 {
     $user = Auth::user();
     $member = Member::where('user_id', $user->id)->first();
     return view('ajax.editMemberProfile', ['profile' => $member]);
 }
Пример #23
0
 public function getResource($resource)
 {
     if (is_string($resource)) {
         if ('amount' == $resource) {
             $country_code = Input::get('country_code');
             $mem_period = Input::get('mem_period');
             // hard coding the currency ID to query payment-heads
             if ('IND' == $country_code) {
                 $currency_id = 1;
             } else {
                 $currency_id = 2;
             }
             Log::info('In getResource: ' . $country_code . $mem_period);
             $head = PaymentHead::getHead($mem_period, $currency_id)->first();
             $data = ['amount' => $head->amount, 'service_tax' => ServiceTaxClass::find($head->service_tax_class_id)->tax_rate];
         } else {
             if ('states' == $resource) {
                 $country_code = Input::get('code');
                 Log::info('In getResource for states: ' . $country_code);
                 // querying with states of india and not regions > states;
                 $states = State::where('country_code', 'like', $country_code)->orderBy('name', 'asc')->get(['state_code', 'name'])->toarray();
                 Log::info('In getResource for states: typeof ' . gettype($states));
                 $data = $states;
             } else {
                 if ('branches' == $resource) {
                     $state_code = Input::get('code');
                     Log::info('In getResource for branches: ' . $state_code);
                     $chapters = CsiChapter::where('csi_state_code', $state_code)->get();
                     $collection = new \Illuminate\Database\Eloquent\Collection();
                     $result = new \Illuminate\Database\Eloquent\Collection();
                     foreach ($chapters as $chapter) {
                         $members = Member::where('csi_chapter_id', $chapter->id)->get();
                         if (!$members->isEmpty()) {
                             $collection = $members->filter(function ($item) {
                                 $curr = $item->subType;
                                 if ($curr->membership_type_id == 1) {
                                     if ($curr->subType->is_student_branch) {
                                         return $item;
                                     }
                                 }
                             });
                         }
                     }
                     foreach ($collection as $member) {
                         $arr = [];
                         $arr['member_id'] = $member->subType->id;
                         $arr['name'] = $member->subType->name;
                         $result->add($arr);
                     }
                     $data = $result->sortBy('name')->toarray();
                 } else {
                     if ('chapters' == $resource) {
                         $state_code = Input::get('code');
                         Log::info('In getResource for chapters: ' . $state_code);
                         $chapters = CsiChapter::where('csi_state_code', $state_code)->orderBy('name', 'asc')->get(['id', 'name'])->toarray();
                         Log::info('In getResource for chapters: typeof ' . gettype($chapters));
                         $data = $chapters;
                     } else {
                         if ('institutions' == $resource) {
                         }
                     }
                 }
             }
         }
         $response = Response::json($data, 200);
     } else {
         $response = Response::json(array('errors' => $e->getMessage()), 500);
     }
     return $response;
 }
 public function save(Request $request)
 {
     $rules = array('email' => 'required|email', 'password' => 'required', 'confirmpassword' => 'required');
     $validator = \Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'message' => $validator->errors()->all()));
     }
     $password = $request->input('password');
     $confirmpassword = $request->input('confirmpassword');
     if ($password != $confirmpassword) {
         return Response::json(array('result' => false, 'message' => 'password and confirm password mismatch.'));
     }
     $member = Member::where('email', $request->input('email'))->first();
     if ($member == null) {
         return Response::json(array('result' => false, 'message' => 'member can not define.'));
     }
     $member->password = md5($password);
     $member->forget_token = null;
     if ($member->save()) {
         return Response::json(array('result' => true, 'message' => 'success'));
     }
     return Response::json(array('result' => false, 'message' => 'save fail.'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, MemberRequest $request)
 {
     $member = Member::find($id);
     $oldOrder = $member->order;
     $newOrder = $request->input('order');
     $type = $request->input('type');
     /* 
     Laravel can not handle using the request manager the validation
     of the size image that exceeds the configuration of php.in
     */
     if ($this->imageHelper->fileImageSizeExceeded($request->file('image'))) {
         //Set the message and the error class
         Session::flash('message', 'The file image can not be greater than 2MB!');
         Session::flash('alert-class', 'alert-danger');
         return redirect()->back();
     }
     //Fill this member with the new form information
     $member->fill($request->all());
     //Getting the max permitted position
     $maxPosition = Member::where('type', $type)->count();
     //If the admin informed a greater position, set the position as the maximum one
     if ($member->order > $maxPosition) {
         $member->order = $maxPosition;
         $newOrder = $maxPosition;
     }
     //Setting the right order
     $this->imageHelper->adjustUpdateOrder($type, $oldOrder, $newOrder, $member);
     //Checking if there was uploaded a image
     if ($request->file('image') != null) {
         //Delete the old member image from the filesystem
         File::delete($member->path);
         //Moves and sets the new uploaded image
         $this->imageHelper->uploadImage($request, $member);
     }
     $member->save();
     //Sending the user to the accounts page
     return redirect()->route('member/index');
 }
Пример #26
0
 public function postMember()
 {
     $member_id = Input::get("member_id");
     $message = trans('locale.member_not_found');
     $member = Member::where('member_id', '=', $member_id)->first();
     if ($member) {
         $message = null;
     }
     return view("member/member")->with("member", $member)->with('message', $message);
 }
Пример #27
0
 public function getAdminTable(Request $r)
 {
     $items = array();
     $query = $r->input("query", "");
     $sort = $r->input("sort", "id");
     $asc = "DESC";
     if ($sort == "old" || $sort == "title") {
         $asc = "ASC";
     }
     if ($sort != "title") {
         $sort = "id";
     }
     switch ($r->input("entity")) {
         case "contents":
             $items = Content::where("type", $r->input("type"))->where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10);
             break;
         case "members":
             $items = Member::where("firstname", "like", "%" . $query . "%")->orWhere("lastname", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10);
             break;
         case "variables":
             $items = Variable::where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(10);
             break;
         case "tags":
             $items = Tag::where("title", "like", "%" . $query . "%")->orderBy($sort, $asc)->simplePaginate(20);
             break;
         case "categories":
             $catcon = new CategoryController();
             $items = $catcon->getTree();
             break;
         default:
             echo "unknown type";
     }
     return view('admintable', ['type' => $r->input('type'), 'entity' => $r->input('entity'), 'items' => $items]);
 }
Пример #28
0
 public function createUsername($username)
 {
     $clientCode = $username . sprintf("%04d", rand(0, 9999));
     $codeCount = Member::where('username', $clientCode)->count();
     if ($codeCount > 0) {
         $this->createUsername($username);
     } else {
         return $clientCode;
     }
 }
Пример #29
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $det = PersonalInformation::where('id', $id)->first();
     if ($det) {
         $ag = Member::where('id', $det->agent_id)->first();
         $em = Member::where('id', $det->approved_by)->first();
         return view('resume.approvalDetail')->with('det', $det)->with('ag', $ag)->with('em', $em);
     }
 }
Пример #30
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $cfg = Config::first();
     // Check config if registration is enabled
     if (!$cfg->registration_enabled) {
         return response()->json(["msg" => "registrations are disabled"], 403);
     }
     $v = Validator::make($request->all(), ['name' => 'required|max:255|unique:groups', 'members' => 'required|array']);
     for ($n = 0; $n < count($request->members); $n++) {
         $v->sometimes("members.{$n}.email", 'required|email|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.password", 'required|confirmed|min:6', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.first_name", 'required|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.last_name", 'required|max:255', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.birthdate", 'required|date', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.sex", 'required|in:m,f', function ($input) use($n) {
             return count($input->members >= $n);
         });
         $v->sometimes("members.{$n}.country", 'required', function ($input) use($n) {
             return count($input->members >= $n);
         });
         //$v->sometimes("members.$n.cv", 'required|mimes:pdf', function($input) use($n) { return count($input->members >= $n); });
     }
     $v->after(function ($validator) use($request) {
         if (count($request->members) < 1 || count($request->members) > 3) {
             $validator->errors()->add('members', 'Only 1-3 members are accepted');
         }
     });
     if ($v->fails()) {
         return response()->json($v->errors(), 400);
     }
     // validate all members have correct auth or do not exist yet
     foreach ($request->members as $m) {
         $qm = Member::where('email', $m['email']);
         if ($qm->exists()) {
             // Check password
             if (!Auth::once(['email' => $m['email'], 'password' => $m['password']])) {
                 return response()->json(["msg" => "User already exists, and password is incorrect", "offender" => $m['email']], 400);
             }
         }
     }
     $group = new Group($request->only('name'));
     $group->save();
     // create or register to the group all the members
     foreach ($request->members as $m) {
         $qm = Member::where('email', $m['email']);
         if (!$qm->exists()) {
             $qm = new Member($m);
             $qm->password = Hash::make($m['password']);
             $group->members()->save($qm);
             // Handle cv PDF
             //if ($m['cv']->isValid()) {
             //    $m['cv']->move(storage_path('app/cvs'), $qm->id.'.pdf');
             //}
         }
     }
     Mail::send('emails.admin.groupCreated', ['group' => $group], function ($m) use($group, $cfg) {
         $m->from('*****@*****.**', 'EESTEC Android Competition');
         $m->to($cfg->admin_email, 'ECA Admin')->subject('New group registered!');
     });
     return response()->json($group);
 }