本文整理汇总了PHP中Illuminate\Support\Facades\Route::getFacadeRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getFacadeRoot方法的具体用法?PHP Route::getFacadeRoot怎么用?PHP Route::getFacadeRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Route
的用法示例。
在下文中一共展示了Route::getFacadeRoot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPermission
public static function checkPermission()
{
$userInfo = Session::get('user');
$uri = new Permission();
$currentRoute = Route::getFacadeRoot()->current()->uri();
if (Cache::has('user')) {
$user = Cache::get('user');
$permission = $user['permission'];
$ck = in_array($userInfo['role_id'] . '|' . $currentRoute, $permission);
} else {
$ck = $uri->where('name', $userInfo['role_id'] . '|' . $currentRoute)->count();
}
if ($ck > 0 || $userInfo['role_id'] == 1) {
return true;
}
return false;
}
示例2: storeUserType
public function storeUserType(Request $request)
{
$rules = ['name' => 'required|min:6', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6', 'phone_number' => 'required', 'age' => 'required|numeric', 'gender' => 'required'];
$messages = ['name.required' => 'Please Enter Your Name.', 'email.required' => 'Please Enter Email Address.', 'password.required' => 'Please enter your password', 'age.required' => 'Please enter your age', 'gender.required' => 'Please Check Your Gender', 'phone_number.required' => 'Please Enter Your Phone Number'];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
$confirmation_code = str_random(30);
//To get User Type
$routeType = Route::getFacadeRoot()->current()->uri();
if ($routeType == 'saveTeacherProfile') {
$userType = 'teacher';
} else {
$userType = 'admin';
}
User::create(['name' => $request->input('name'), 'email' => $request->input('email'), 'gender' => $request->input('gender'), 'age' => $request->input('age'), 'password' => bcrypt($request->input['password']), 'confirmation_code' => $confirmation_code, 'phone_number' => $request->input('phone_number'), 'user_type' => $userType]);
$data = array('confirmation_code' => $confirmation_code, 'name' => Input::get('name'));
Mail::send('email.verify', $data, function ($message) {
$message->to(Input::get('email'), Input::get('name'))->subject('Verify your email address');
});
Session::flash('success', 'Sir,Thanks for signing up! Please check your email.');
return Redirect::to('student-registration');
}
示例3: compose
/**
* Bind data to the view.
*
* @param \Illuminate\Contracts\View\View $view View object
*
* @return void
*/
public function compose(\Illuminate\Contracts\View\View $view)
{
$view->with('currentRoute', $this->route->getFacadeRoot()->currentRouteName());
}
示例4: getDefaultRoute
/**
* Get a default route value, if any is available
*
* @return Registrar|null A default route value or Null if no default value is available
*/
public function getDefaultRoute()
{
return Route::getFacadeRoot();
}
示例5: __construct
public function __construct()
{
$this->router = \Illuminate\Support\Facades\Route::getFacadeRoot();
}
示例6: loginPost
public function loginPost(Request $request)
{
//validate input
$v = Validator::make($request->all(), ['email' => 'required|email', 'password' => 'required']);
//recaptcha implementation
//TODO after 5 attempt show recaptcha
//$recaptcha = new \ReCaptcha\ReCaptcha(Setting::getSetting('recaptchasecret'));
//$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if ($v->fails()) {
$errors = $v->errors();
$return['status'] = false;
$return['errors'] = $errors;
}
$userdata = array('email' => $request->get('email'), 'password' => $request->get('password'));
$remember = false;
if ($request->has('remember_me') && $request->get('remember_me') == 1) {
$remember = true;
}
if (Auth::attempt($userdata, $remember)) {
$currentPath = Route::getFacadeRoot()->current()->uri();
$return['status'] = true;
$return['url'] = url($currentPath);
} else {
$return['status'] = false;
$return['errors'] = ['general' => ['Please check your email and/or password or register']];
}
return $return;
}