本文整理匯總了PHP中Illuminate\Support\Facades\Auth::check方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::check方法的具體用法?PHP Auth::check怎麽用?PHP Auth::check使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::check方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: start
public function start()
{
if (Auth::check()) {
return \View::make('dashboard')->with('name', 'ritesh');
}
return Redirect::to('auth/login');
}
示例2: edit
public function edit(Donations $donations)
{
if (!Auth::check()) {
return redirect('donations');
}
return view('edit', compact('donations'));
}
示例3: it_logs_a_user_out
/**
* @test
*/
public function it_logs_a_user_out()
{
$this->preparePageContent();
$user = factory('App\\User')->create();
$this->actingAs($user)->visit('admin/logout');
$this->assertFalse(Auth::check(), 'user not logged out');
}
示例4: addTask
public function addTask(Request $req, $name_liste)
{
$param = $req::all();
if ($param['task'] != "" && strtotime($param['date']) != 0) {
$tache = new \App\Tache();
$tache->name_user = Auth::user()->email;
$tache->name_liste = $name_liste;
$tache->etat_tache = "No";
$tache->tache = $param['task'];
$tache->date = $param['date'];
$tache->save();
// Update nombre de tâche de Liste
$log = Auth::user()->email;
$liste = new \App\Liste();
$liste = Liste::where('name_liste', $name_liste)->where('name_user', $log)->first();
$liste->tache_tot = $liste->tache_tot + 1;
$liste->save();
return redirect()->route('index');
} else {
//
//$this->fail = 'erreur';
//echo $this->fail ;
if (Auth::check()) {
$log = Auth::user()->email;
$todo = DB::table('listes')->where('name_user', $log)->get();
} else {
$todo = null;
}
$this->erreur = "yes";
return view('index', ['todo' => $todo, 'erreur' => $this->erreur]);
}
}
示例5: handle
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return redirect('/login');
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (!Auth::check() || !Auth::guard($guard)->user()->admin) {
return redirect('/');
}
return $next($request);
}
示例7: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
if (Auth::check()) {
return redirect('/home');
}
return view('auth.login');
}
示例8: handle
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->isAdmin()) {
return $next($request);
}
return redirect('/');
}
示例9: authorize
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (Auth::check()) {
return true;
}
return false;
}
示例10: earnedAchievements
public function earnedAchievements()
{
if (empty($this->earned)) {
if (Auth::check()) {
$from_lesson = $this->course->achievements()->where('lesson_id', $this->id)->get();
$from_num_lessons = [];
$fnl = $this->course->achievements()->whereNotNull('num_lessons')->get();
foreach ($fnl as $a) {
if (Auth::user()->lessons()->where('course_id', $this->course->id)->count() >= $a->num_lessons) {
$from_num_lessons[] = $a;
}
}
$achievements = array_merge($from_lesson->all(), $from_num_lessons);
//$own_achievements = Auth::user()->achievements;
$earned = [];
foreach ($achievements as $a) {
if (Auth::user()->achievements()->where('achievement_id', $a->id)->count() == 0) {
$earned[] = $a;
}
}
foreach ($earned as $a) {
Auth::user()->achievements()->attach($a->id);
}
$this->earned = $earned;
return collect($earned);
} else {
return collect([]);
}
} else {
return collect($this->earned);
}
}
示例11: newPost
/**
* Create a new post
* @param string $body Content of post, will be run through filters
* @param integer $threadid Thread ID
* @param integer| $posterid Poster's ID. Defaults to currently authenticated user
* @param bool|false $hidden Is the post hidden from normal view?
* @param bool|true $save Should the post be automatically saved into the database?
* @return Post The resulting post object
*/
public static function newPost($body, $threadid, $posterid = null, $hidden = false, $save = true)
{
// Check users rights
if (!Auth::check() && $posterid === null) {
abort(403);
// 403 Forbidden
}
// Check thread
$thread = Thread::findOrFail($threadid);
if ($thread->locked) {
abort(403);
// 403 Forbidden
}
// Run post through filters
$body = PostProcessor::preProcess($body);
// Create new post
$post = new Post();
$post->thread_id = $threadid;
$post->poster_id = Auth::user()->id;
$post->body = $body;
$post->hidden = $hidden;
// defaults to false
// Put post into database
if ($save) {
$post->save();
}
return $post;
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->username == Auth::user()->facebook_id && strpos($request->route()->getName(), 'user') === false) {
return redirect()->route('user/editSelf')->with('message', 'You must finish editing your account.');
}
return $next($request);
}
示例13: getLoginAction
public function getLoginAction()
{
if (Auth::check()) {
return redirect('/admin');
}
return view('admin.login');
}
示例14: login
public function login()
{
if (Auth::check() && Auth::user()->isAdmin()) {
return redirect('admin/dashboard');
}
return view('auth/admin-login', ['body_class' => 'login']);
}
示例15: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
if (Auth::check() && Auth::user()->admin) {
return redirect()->route('admin');
}
return redirect()->route('etudiant');
}