/** * Store a newly created resource in storage. * * @return Response */ public function store() { $this->loginForm->validate($input = Input::only('email', 'password')); try { Sentry::authenticate($input, true); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { $mjs = array('success' => false, 'mgs' => trans('main.mgs_invalid_credential'), 'url' => ''); return Response::json($mjs); } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) { $mjs = array('success' => false, 'mgs' => trans('main.user_not_activated'), 'url' => ''); return Response::json($mjs); } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) { $mjs = array('success' => false, 'mgs' => trans('main.user_suspended'), 'url' => ''); return Response::json($mjs); } // Logged in successfully - redirect based on type of user $user = Sentry::getUser(); $admin = Sentry::findGroupByName('Admins'); $users = Sentry::findGroupByName('Patients'); $doctors = Sentry::findGroupByName('Doctors'); $company = Sentry::findGroupByName('Clinics'); $recepcion = Sentry::findGroupByName('Receptionist'); if ($user->inGroup($admin)) { $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/admin'); return Response::json($mjs); } elseif ($user->inGroup($company) or $user->inGroup($recepcion)) { $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/clinic'); return Response::json($mjs); } elseif ($user->inGroup($doctors)) { $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/doctor'); return Response::json($mjs); } elseif ($user->inGroup($users)) { return Redirect::to(url()); } }
/** * Store a newly created resource in storage. * POST /sessions/store. * * @return Response */ public function store() { // Set login credentials $input = array('email' => Input::get('email'), 'password' => Input::get('password')); // Try to authenticate the user try { Sentry::authenticate($input, Input::has('remember')); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { return Redirect::back()->withInput()->withErrorMessage('Invalid credentials provided'); } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) { return Redirect::back()->withInput()->withErrorMessage('User Not Activated.'); } // Logged in successfully - redirect based on type of user $user = Sentry::getUser(); $adminsGroup = Sentry::findGroupByName('Admins'); $usersGroup = Sentry::findGroupByName('Users'); if ($user->inGroup($adminsGroup)) { return Redirect::intended('admin'); } elseif ($user->inGroup($usersGroup)) { if (!stripos(Session::get('url.intended', '/'), '/admin')) { return Redirect::intended('/'); } else { return Redirect::to('/'); } } }
public function refunds() { $properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get(); $refunds = Invoice::where('type', '=', 'refund')->get(); $amountpaid = 0; return View::make('backend.code.invoice.refunds', compact('refunds', 'amountpaid', 'properties')); }
public function isCurrent() { if (!Sentry::check()) { return false; } return Sentry::getUser()->id == $this->id; }
public function add_feedback() { $type = Input::get('type'); $title = Input::get('title'); $content = Input::get('content'); if (!isset($type)) { return Response::json(array('errCode' => 1, 'message' => '请选者反馈类型')); } if (!isset($title)) { return Response::json(array('errCode' => 2, 'message' => '请输入标题')); } if (!isset($content)) { return Response::json(array('errCode' => 3, 'message' => '请输入内容')); } $feedback = new Feedback(); $feedback->user_id = Sentry::getUser()->user_id; $feedback->type = $type; $feedback->title = $title; $feedback->content = $content; $feedback->status = 0; if (!$feedback->save()) { return Response::json(array('errCode' => 4, 'message' => '保存失败')); } return Response::json(array('errCode' => 0, 'message' => '保存成功')); }
public function __construct() { if (Sentry::check()) { // User is not logged in, or is not activated $this->data['admin'] = Sentry::getUser(); } }
public function postReply() { try { $board_id = Arr::get($_POST, 'board_id', null); $labels = Arr::get($_POST, 'labels', array()); $content = Arr::get($_POST, 'content', ''); if ($board_id === null || empty($content)) { throw new Exception('回覆失敗'); } $br = new BoardReply(); $br->tags = serialize($labels); $br->content = $content; $br->creator = Sentry::getUser()->getId(); $br->created_at = date('Y-m-d H:i:s'); $br->board_id = $board_id; $br->save(); //update status of board $b = Board::find($board_id); $b->isReply = '1'; $b->save(); return Redirect::route('admin.board.list'); } catch (Exception $e) { return Redirect::back()->withInput()->withErrors($e->getMessage()); } }
public function pushMessage() { if (!Sentry::check()) { return Response::json(array('errCode' => 10, 'message' => '请登录')); } Sentry::login(Sentry::findUserById(5), false); $user = Sentry::getUser(); // $user = User::find(1); $push_status = PushStatus::where('user_id', $user->id)->first(); if (count($push_status) == 0) { $push_status = new PushStatus(); $push_status->user_id = $user->id; $push_status->status = 1; if (!$push_status->save()) { return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } if ($push_status->status == 1) { $push_status->status = 0; if (!$push_status->save()) { return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } if ($push_status->status == 0) { $push_status->status = 1; if (!$push_status->save()) { return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } }
/** * AdminUserController::postLogin() * * @return */ public function postLogin() { $userService = new UserAccountService(); $rules = array('email' => 'Required|email', 'password' => 'Required'); $validator = \Validator::make(\Input::all(), $rules); if (!$validator->fails()) { $user = array('email' => \Input::get('email'), 'password' => \Input::get('password')); $remember = \Input::get('remember'); $error = $userService->doLogin($user, $remember); if ($error == '') { $redirect = ''; if (\Sentry::getUser()->hasAnyAccess(['system'])) { $redirect = \Config::get('webshopauthenticate::admin_uri'); } else { $redirect = \Config::get('webshopauthenticate::uri') . '/myaccount'; } return \Redirect::intended($redirect); } $error_msg = ''; if ($error == 'Invalid') { $error_msg = \Lang::get('webshopauthenticate::auth/form.login.invalid_login'); } else { if ($error == 'ToActivate') { $error_msg = \Lang::get('webshopauthenticate::auth/form.login.account_not_confirmed'); } } \Session::flash('error', $error_msg); return \Redirect::to(\Config::get('webshopauthenticate::uri') . '/login')->withInput(); } else { return \Redirect::to(\Config::get('webshopauthenticate::uri') . '/login')->withErrors($validator->messages())->withInput(); } }
public function settings() { $user = Sentry::getUser(); if (Input::get('email') == $user->email) { $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50'); } else { $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50'); } $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Response::json($validator->messages()); } else { $setting = Setting::first(); $setting->sitename = Input::get('sitename'); $setting->save(); $user = User::find($user->id); $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->email = Input::get('email'); $user->password = Input::get('password'); $user->save(); $feedback = array('success' => 'Settings successfully saved.'); return Response::json($feedback); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // Fetch all request data. $data = Input::only('title', 'extra_url', 'event_id'); $event_id = Input::get('event_id'); // Build the validation constraint set. $rules = array('title' => array('required', 'min:3'), 'extra_url' => array('required', 'Url'), 'event_id' => array('required', 'integer', 'sometimes')); // Create a new validator instance. $validator = Validator::make($data, $rules); if ($validator->passes()) { $extra = new Extra(); $current_user = Sentry::getUser(); if ($current_user->hasAccess('admin') || $current_user->hasAccess('verified')) { $extra->approved = '1'; } $extra->author_id = Sentry::getUser()->id; $extra->title = Input::get('title'); $extra->extra_url = Input::get('extra_url'); $extra->save(); $event = ep\Event::find($event_id); $event->eventExtra()->save($extra); return Redirect::to('/event/' . $event->slug)->with('global_success', 'Event submitted successfuly!'); } return Redirect::to('/event/' . $event->slug)->withInput()->withErrors($validator)->with('message', 'Validation Errors!'); }
/** * View a blog post. * * @param string $slug * @return Redirect */ public function postView($slug) { // The user needs to be logged in, make that check please. if (!Sentry::check()) { return Redirect::to($slug . '#comments')->with('error', 'You need to be logged in to post comments!'); } // Get this blog post data $post = Post::where('slug', '=', $slug)->first(); // Declare the rules for the form validation $rules = array('comment' => 'required|min:3'); // Validate the inputs $validator = Validator::make(Input::all(), $rules); // Check if the form validates with success if ($validator->passes()) { // Save the comment $comment = new Comment(); $comment->user_id = Sentry::getUser()->id; $comment->content = Input::get('comment'); // Was the comment saved with success? if ($post->comments()->save($comment)) { // Redirect to this blog post page return Redirect::to($slug . '#comments')->with('success', 'Your comment was added with success.'); } // Redirect to this blog post page return Redirect::to($slug . '#comments')->with('error', 'There was a problem adding your comment, please try again.'); } // Redirect to this blog post page return Redirect::to($slug)->withInput()->withErrors($validator); }
public function requestRefund() { $order_id = Input::get('order_id'); $order = AgencyOrder::find($order_id); if (!isset($order)) { return Response::json(array('errCode' => 21, 'message' => '该订单不存在')); } $refund_record = RefundRecord::where('order_id', '=', $order_id)->get(); if (count($refund_record) != 0) { return Response::json(array('errCode' => 22, 'message' => '申请已提交')); } if ($order->trade_status != 1 || $order->process_status != 1) { return Response::json(array('errCode' => 23, 'message' => '该订单不可申请退款')); } try { DB::transaction(function () use($order) { $order->trade_status = 2; $order->save(); $refund_record = new RefundRecord(); $refund_record->order_id = $order->order_id; $refund_record->user_id = Sentry::getUser()->user_id; $refund_record->save(); }); } catch (Exception $e) { return Response::json(array('errCode' => 24, 'message' => '退款申请失败,请重新申请')); } return Response::json(array('errCode' => 0, 'message' => '申请成功')); }
public function execute($function) { if (Sentry::check() && Sentry::getUser()->isSuperUser()) { return $function(); } return 'You have no privileges to access this page!'; }
/** * View a blog post. * * @param string $slug * @return Redirect */ public function postView($slug) { // The user needs to be logged in, make that check please if (!Sentry::check()) { return Redirect::to("blog/{$slug}#comments")->with('error', 'You need to be logged in to post comments!'); } // Get this blog post data $post = Post::where('slug', $slug)->first(); // Declare the rules for the form validation $rules = array('comment' => 'required|min:3'); // Create a new validator instance from our dynamic rules $validator = Validator::make(Input::all(), $rules); // If validation fails, we'll exit the operation now if ($validator->fails()) { // Redirect to this blog post page return Redirect::to("blog/{$slug}#comments")->withInput()->withErrors($validator); } // Save the comment $comment = new Comment(); $comment->user_id = Sentry::getUser()->id; $comment->content = e(Input::get('comment')); // Was the comment saved with success? if ($post->comments()->save($comment)) { // Redirect to this blog post page return Redirect::to("blog/{$slug}#comments")->with('success', 'Your comment was successfully added.'); } // Redirect to this blog post page return Redirect::to("blog/{$slug}#comments")->with('error', 'There was a problem adding your comment, please try again.'); }
public function getProdlist() { $user = Sentry::getUser()->id; // $content = View::make('backend.widgets.prodlist'); // return View::make('backend.general', compact('content')); return View::make('backend.widgets.prodlist'); }
/** * Store a newly created payment in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Payment::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } if (Input::hasFile('attachment')) { $no = Payment::max('id') + 1; $noinvoice = 'AT' . date('Ymd') . $no; $uploaded_file = Input::file('attachment'); $extension = $uploaded_file->getClientOriginalExtension(); $filename = Sentry::getUser()->first_name . '.' . $extension; $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'uploads/payments'; $uploaded_file->move($destinationPath, $filename); // 25 $data['noinvoice'] = $noinvoice; $data['attachment'] = $filename; $data['school'] = Sentry::getUser()->first_name; $data['year'] = date('Y'); $data['verifikasi'] = 0; $data['user_id'] = Sentry::getUser()->id; Payment::create($data); return Redirect::to('user/cost')->with("successMessage", "Konfirmasi Pembayaran berhasil dimasukkan"); } }
public function postCreate() { $rules = array('name' => 'required', 'cover_image' => 'required|image'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('create_album_form')->withErrors($validator)->withInput(); } // end if $file = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $file->getClientOriginalExtension(); $filename = $random_name . "." . $extension; $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename); $album = Album::create(array('name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename, 'user_id' => \Sentry::getUser()->id)); /* $filename = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $filename->getClientOriginalExtension(); $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename . "." . $extension); $album = Album::create(array( 'name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename . "." . $extension, )); */ return Redirect::route('show_album', array('id' => $album->id)); }
/** * View a blog post. * * @param string $slug * @return Redirect */ public function postView($slug) { // The user needs to be logged in, make that check please if (!Sentry::check()) { return Redirect::to("blog/{$slug}#comments")->with('error', Lang::get('post.messages.login')); } // Get this blog post data $post = $this->post->where('slug', $slug)->first(); // get the data $new = Input::all(); $comment = new Comment(); // If validation fails, we'll exit the operation now if ($comment->validate($new)) { // Save the comment $comment->user_id = Sentry::getUser()->id; $comment->content = e(Input::get('comment')); // Was the comment saved with success? if ($post->comments()->save($comment)) { // Redirect to this blog post page return Redirect::to("blog/{$slug}#comments")->with('success', 'Your comment was successfully added.'); } } else { // failure, get errors return Redirect::to("blog/{$slug}#comments")->withInput()->withErrors($comment->errors()); } // Redirect to this blog post page return Redirect::to("blog/{$slug}#comments")->with('error', Lang::get('post.messages.generic')); }
protected function setUp() { $this->current_route = Route::getCurrentRoute()->getName(); $this->logged_user = Sentry::getUser(); View::share('logged_user', $this->logged_user); View::share('current_route', $this->current_route); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $userRepo = \App::make('Gruik\\Repo\\User\\UserInterface'); $user = $userRepo->byId($id); if ($user && $user->id == \Sentry::getUser()->id) { $inputs = Input::all(); // Password change $new_password = array_pull($inputs, 'new_password', false); $new_password_conf = array_pull($inputs, 'new_password_conf', false); $email = array_pull($inputs, 'email', false); if ($new_password || $new_password_conf) { if ($new_password == $new_password_conf) { $user->password = $new_password; } else { return \Response::json(['flash' => 'Passwords must be the same !'], 400); } } // Email change if ($email != $user->email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $user->email = $email; } else { return \Response::json(['flash' => 'Email address is not valid !'], 400); } } // Preferences $preferences = array_pull($inputs, 'preferences', false); $userRepo->setPreferencesForUser($id, $preferences); $user = $user->fill($inputs); $user->save(); return \Response::json($user, 200); } else { return \Response::json("Unauthorized : User doesn't exist OR you can't modify it", 400); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // var_dump(Input::All()); // die; // // 'categorias_id' => 'exists:rubros,id' $rules = ['articulo' => 'required', 'copete' => 'required', 'texto' => 'required']; if (!Articulo::isValid(Input::all(), $rules)) { return Redirect::back()->withInput()->withErrors(Articulo::$errors); } $articulo = new Articulo(); $articulo->users_id = Sentry::getUser()->id; $articulo->articulo = Input::get('articulo'); $articulo->copete = Input::get('copete'); $articulo->texto = Input::get('texto'); $articulo->tipo = Input::get('tipo'); $articulo->categorias_id = Input::get('categorias_id'); $url_seo = Input::get('articulo'); $articulo->estado = 'nuevo'; //$url_seo = $this->url_slug($url_seo) . implode("-",getdate()); $url_seo = $this->url_slug($url_seo) . date('ljSFY'); $articulo->url_seo = $url_seo; $articulo->save(); return Redirect::to('/articulos/ver'); }
/** * Users settings form processing page. * * @return Redirect */ public function postIndex() { // Declare the rules for the form validation $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users,email,' . Sentry::getUser()->email . ',email'); // If we are updating the password if (Input::get('password')) { // Update the validation rules $rules['password'] = '******'; $rules['password_confirmation'] = 'required'; } // Validate the inputs $validator = Validator::make(Input::all(), $rules); // Check if the form validates with success if ($validator->passes()) { // Update the user $user = Sentry::getUser(); $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->email = Input::get('email'); // Are we updating the user password? if (Input::get('password')) { $user->password = Input::get('password'); } // Save the user $user->save(); // Redirect to the register page return Redirect::to('account/settings')->with('success', 'Account updated with success!'); } // Something went wrong return Redirect::to('account/settings')->withInput()->withErrors($validator->messages()); }
public static function canEdit($id) { if (Sentry::check() && (Sentry::getUser()->id == $id || Sentry::getUser()->isSuperUser())) { return true; } return false; }
public function __construct() { $this->user = Sentry::getUser(); $this->isAdmin = User::isAdmin($this->user); $this->logged_in_for = $this->user->last_login->diffForHumans(); $this->configs = Setting::getSiteSettings(); }
public function do_help() { $user = Sentry::getUser(); $subject = "Newsletter Help: " . Input::get('subject'); $emailbody = Input::get('message'); $from_name = $user->first_name . ' ' . $user->last_name; $from_email = $user->email; $admin = User::first(); $to_name = $admin->first_name . ' ' . $admin->last_name; $to_email = $admin->email; $rules = array('subject' => 'required|max:128', 'message' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('dashboard/help')->withErrors($validator); } else { $browser = new Browser(); $userbrowser = $browser->getBrowser() . ' ' . $browser->getVersion(); $userplatform = $browser->getPlatform(); $userIP = $_SERVER["REMOTE_ADDR"]; $page = URL::current(); $data = array('emailbody' => $emailbody, 'userbrowser' => $userbrowser, 'userplatform' => $userplatform, 'userIP' => $userIP, 'page' => $page); $issent = Mail::send('emails.help-email', $data, function ($message) use($from_email, $from_name, $subject, $to_name, $to_email) { $message->from($from_email, $from_name)->to($to_email, $to_name)->subject($subject); }); if ($issent) { return Redirect::to('dashboard/help')->with('success', 'Success! You will be contacted soon regarding your issue.'); } else { return Redirect::to('dashboard/help')->with('error', 'An error was encountered sending the email. Please try again.'); } } }
public function index() { // todo this should be moved into the repo $user = Sentry::getUser(); $faxes = $this->faxes->findByUserId($user->getId()); $this->view('fax.list', compact('faxes')); }
public function assessmentupdateget($dash, $id) { $assessment = Assessments::find($id); $user = User::find($assessment->teacherid); if (Sentry::getUser()->id == $user->id) { $theme = Theme::uses('dashboard')->layout('default'); $view = array('name' => 'Dashboard Assessment Update', 'id' => $id); $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Assessments', 'url' => Setting::get('system.dashurl') . '/assessments'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/assessment/' . $id]]); $theme->appendTitle(' - Assessment Update'); $theme->asset()->container('datatable')->writeScript('inline-script', '$(document).ready(function(){ $(\'#attachments\').dataTable({ "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>", "oLanguage": { "sLengthMenu": "_MENU_ ' . ' Attachments per page" }, "sPagination":"bootstrap" }); });$(document).ready(function(){ $(\'#questionfail\').dataTable({ "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>", "oLanguage": { "sLengthMenu": "_MENU_ ' . ' Failures per page" }, "sPagination":"bootstrap" }); });'); $theme->asset()->container('footer')->writeScript('inline-script', '$(document).ready(function(){ $("#examsheader").hide(); $("div#exams").hide(); $("div#examslock").hide(); $(".hidequestions").hide(); $(".hidequestions").click(function(){ $("div#exams").hide(2000); $(\'html, body\').animate({ scrollTop: $("#top").offset().top }, 2000); $("#examsheader").hide(1200); $("#examslock").hide(1200); $(".hidequestions").hide(1000); $("#showquestions").show(1000); }); $("#showquestions").click(function(){ $("div#exams").show(2000); $("div#examslock").show(100); $(\'html, body\').animate({ scrollTop: $("#examslock").offset().top }, 2000); $("#examsheader").show(1000); $(".hidequestions").show(1000); $("#showquestions").hide(1000); }); });'); return $theme->scope('assessment.update', $view)->render(); // return View::make('dashboard.assessments.update')->with('id',$id); } else { return "UPDATE NOT AUTHORISED"; } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // exit(); // First make sure there is an active session // dd(debug_print_backtrace(2)); // dd(Sentry::check()); if (!Sentry::check()) { // return $next($request); exit('tidak login'); if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect()->guest(route('sentinel.login')); } } // Now check to see if the current user has the 'admin' permission // dd(get_class(Sentry::getUser())); // dd(Sentry::getUser()->hasAccess('admin'));//Sentinel\Models\User if (Sentry::getUser()->hasAccess('admin')) { dd('admin'); return $next($request); } // dd($request->route()->getActionName());//"App\Http\Controllers\ExcelController@getIndex" if (!Sentry::getUser()->hasAccess('admin')) { // echo 'masukkk bukan admin<br>'; // dd(\Sentry::getUser()->getGroups()[0]->pivot->group_id); //ambil group_id lewat user_id -> lewat pivot users_group $group_id = \Sentry::getUser()->getGroups()[0]->pivot->group_id; // dd($group_id); //melalui group model dengan id diatas => untuk mengambil akses menu ( menghasilkan list akses menu) $akses = Group::find($group_id)->akses()->get()->toArray(); // $akses = Group::find($group_id)->akses->get()->toArray(); // dd($akses); // echo $akses; $currentRoute = $request->route()->getActionName(); // dd($currentRoute).'-----<br>'; foreach ($akses as $key => $value) { $action = $value['controller'] . '@' . $value['controller_method']; // $action=$value['controller']; if ($action == $currentRoute && $value['akses'] == 1) { // var_dump( $currentRoute == $action ); return $next($request); } } return response('Unauthorized.', 401); } // dd(Sentry::getUser()->hasAccess('admin')); // dd(Sentry::getId()); // dd(Sentry::getGroups()); // All clear - we are good to move forward // return $next($request); if ($request->ajax()) { dd('ajaxx'); return response('Unauthorized.', 401); } else { Session::flash('error', trans('Sentinel::users.noaccess')); return redirect()->route('sentinel.login'); } }
public static function getIdForUser($unescaped_input) { if (!static::isFullMultipleCompanySupportEnabled() || Sentry::getUser()->isSuperUser()) { return static::getIdFromInput($unescaped_input); } else { return static::getIdForCurrentUser($unescaped_input); } }