本文整理汇总了PHP中App\Http\Controllers\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
public function logout()
{
Auth::logout();
// logout user
return Redirect::to('admin/login');
//redirect back to login
}
示例2: index
public function index()
{
$questions = Question::all();
$tpl['user'] = \Auth::user();
$tpl['questions'] = $questions;
return view('home', $tpl);
}
示例3: postStore
public function postStore(UsersRequest $request = null, $id = "")
{
$input = $request->except('save_continue', 'password_confirmation');
$result = '';
if (\Input::hasFile('photo')) {
$photo = (new \ImageUpload($input))->upload();
}
if ($id == "") {
$input['photo'] = isset($photo) ? $photo : "";
$input['active'] = $input['active'];
$input['group_id'] = $input['group_id'];
$input['created_by'] = \Auth::user()->username;
$input['password'] = bcrypt($input['password']);
$query = $this->model->create($input);
$result = $query->id;
} else {
$input['active'] = $input['active'];
$input['group_id'] = $input['group_id'];
if (\Input::hasFile('photo')) {
$input['photo'] = isset($photo) ? $photo : "";
}
if (isset($input['password']) && $input['password'] != "") {
$input['password'] = bcrypt($input['password']);
}
$this->model->find($id)->update($input);
$result = $id;
}
$save_continue = \Input::get('save_continue');
$redirect = empty($save_continue) ? $this->url : $this->url . '/edit/' . $result;
return redirect($redirect)->with('message', 'Admin saved successfully!');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CreateEventRequest $req)
{
$input = $req->all();
// Makes sure chair_id enters database as an integer or null if left empty.
strcmp($input['chair_id'], "") == 0 ? $input['chair_id'] = null : ($input['chair_id'] = (int) $input['chair_id']);
// Ensures database times are always in UTC.
foreach ($input as $key => $value) {
// Ensures only time fields are changed.
if (!strpos($key, 'time')) {
continue;
}
// Converts time from PST to UTC.
$pst = new Carbon($value, 'America/Los_Angeles');
$utc = $pst->setTimezone('UTC');
// Sets date/time string back into values for database.
$input[$key] = $utc->toDateTimeString();
}
$input['creator_id'] = \Auth::id();
// Set creator ID by default
// Set default close time if needed
if (!isset($input['close_time'])) {
$input['close_time'] = $input['start_time'];
}
// Set default open time if needed
if (!isset($input['open_time'])) {
$input['open_time'] = Carbon::now();
}
// Create event
$event = Event::create($input);
return redirect()->action('EventsController@show', $event->slug);
}
示例5: create
public function create()
{
if (Auth::check()) {
return Redirect::to("/admin");
}
return View::make("sessions.create");
}
示例6: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$campaign = \Session::get('campaign');
$campaign->fillRelations();
foreach ($campaign->getRelations() as $relation) {
foreach ($relation as $title => $components) {
//Split it out into human readable terms
$pieces = explode('\\', $title);
$title_component = $pieces[count($pieces) - 1];
$data['objects'][$title_component] = $components;
}
}
$data['campaigns'] = CampaignMembership::where('user_id', \Auth::user()->id)->get();
foreach ($data['campaigns'] as $campaign) {
$campaign->details;
}
$data['object_count'] = count($data['objects']);
$data['columns'] = 5;
$data['logs'] = QuestLog::where('campaign_id', \Session::get('campaign')->id)->orderBy('id', 'desc')->get();
//Let's remove restricted content for non dms
foreach ($data['logs'] as $key => $value) {
foreach ($value as $component) {
if ($value->restricted == 1 && \Session::get('dm') == 0) {
unset($data['logs'][$key]);
}
}
}
return view('dashboards.index')->with($data);
}
示例7: favorites
public function favorites()
{
$favorites = \Auth::user()->sqls()->get();
$page_title = 'SQL';
$page_description = 'Favorites';
return view('sql.favorites', compact('favorites', 'page_title', 'page_description'));
}
示例8: getCreate
public function getCreate(Request $request)
{
$accounts = \App\Account::where('user_id', '=', \Auth::id())->find($request->id);
$transactions = new \App\Transaction();
$categories = ['Deposit/Credit', 'Automobile', 'Groceries', 'Health & Beauty', 'Home Improvement', 'Meals & Entertainment', 'Medical Expense', 'Utilities', 'Insurance', 'Miscellaneous'];
return view('transaction.create')->with('transactions', $transactions)->with(['categories' => $categories])->with('accounts', $accounts);
}
示例9: handleFacebookCallback
public function handleFacebookCallback()
{
//Since its the same callback function for registration & login. Check prev url and handle appropriately
$prevUrl = session()->previousUrl();
$facebookUser = Socialize::with('facebook')->user();
$appUser = User::whereEmail($facebookUser->getEmail())->get();
if (strpos($prevUrl, "register")) {
//If user is not already registered, register and login
if ($appUser->count() == 0) {
$user = User::create(['name' => $facebookUser->getName(), 'email' => $facebookUser->getEmail(), 'password' => str_random(8)]);
$user->verified = true;
$user->token = null;
$user->save();
session()->flash('message', 'You are now registered. Please update your account details.');
\Auth::loginUsingId($user->id);
return redirect('/myAccount');
} else {
return redirect()->back()->withErrors('User already exists');
}
} else {
if ($appUser->count() == 0) {
return redirect()->back()->withErrors('User not found');
}
$user = $appUser[0];
}
\Auth::loginUsingId($user->id);
return redirect()->intended('/dashboard');
}
示例10: inbox
public function inbox()
{
$name = \Auth::user()->name;
$results = \DB::select('select * from notification.inbox_' . $name . ' order by created_at desc limit 70 offset 0');
\DB::update('update notification.inbox_' . $name . ' set n_read = true');
return view('profile.inbox')->with('results', $results);
}
示例11: refresh
public function refresh()
{
$count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count();
if ($count) {
return $count;
}
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$pro_exc = PromotionExceptional::where('user_id', \Auth::user()->id)->first();
if ($pro_exc) {
$pro_exc->start = Carbon::parse($request->start);
$pro_exc->end = Carbon::parse($request->end);
$pro_exc->user_id = \Auth::user()->id;
$pro_exc->price = $request->prix_exc;
$pro_exc->active = 1;
$pro_exc->save();
} else {
$pro_exc = new PromotionExceptional();
$pro_exc->start = Carbon::parse($request->start);
$pro_exc->end = Carbon::parse($request->end);
$pro_exc->price = $request->prix_exc;
$pro_exc->user_id = \Auth::user()->id;
$pro_exc->active = 1;
$pro_exc->save();
}
// make promotion in advance not current
$pro_adv = PromotionAdvance::where('user_id', \Auth::user()->id)->get();
if (!$pro_adv->isEmpty()) {
foreach ($pro_adv as $item) {
$pv = PromotionAdvance::where('user_id', \Auth::user()->id)->where('id', $item->id)->first();
$pv->active = 0;
$pv->save();
}
}
return redirect()->back()->with('success', 'Bien Enregistrée');
}
示例13: index
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
if (\Auth::guest()) {
return redirect()->action('HomeController@index');
}
return redirect('auth/login');
}
示例14: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
$user = \Auth::user();
$friends = $user->friends()->get();
$comments = $user->comments()->get();
return view('users.show')->with(["user" => $user, "friends" => $friends, 'comments' => $comments]);
}
示例15: editQuestion
/**
* edit the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function editQuestion($id)
{
$question = \App\Question::find($id);
$fiche_id = Session::get('fiche_id');
$user = \Auth::user();
return view('back.editQuestion', compact('question', 'fiche_id', 'user'));
}