当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::user方法代码示例

本文整理汇总了PHP中App\Http\Controllers\Auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user方法的具体用法?PHP Auth::user怎么用?PHP Auth::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\Auth的用法示例。


在下文中一共展示了Auth::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: record

 public function record()
 {
     if (\Request::hasFile('image') && \Request::file('image')->isValid() && \Auth::user()->suspend == false) {
         $file = \Request::file('image');
         $input = \Request::all();
         $date = new \DateTime();
         if (isset($input['anon'])) {
             $name = 'anon';
         } else {
             $name = \Auth::user()->name;
         }
         $validator = \Validator::make(array('image' => $file, 'category' => $input['category'], 'title' => $input['title'], 'caption' => $input['caption']), array('image' => 'required|max:1200|mimes:jpeg,jpg,gif', 'category' => 'required', 'title' => 'required|max:120', 'caption' => 'required|max:360'));
         if ($validator->fails()) {
             return redirect('/publish')->withErrors($validator);
         } else {
             $unique = str_random(10);
             $fileName = $unique;
             $destinationPath = 'database/pictures/stream_' . $input['category'] . '/';
             \Request::file('image')->move($destinationPath, $fileName);
             \DB::insert('insert into public.moderation (p_cat, p_ouser, p_title, p_caption, p_imgurl, p_status, p_reported, p_rating, created_at, updated_at) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [$input['category'], $name, $input['title'], $input['caption'], $unique, 'available', 0, 0, $date, $date]);
             $messages = 'Your content has been succesfully submitted. Going on moderation process.';
             return redirect('/system/notification')->with('messages', $messages);
         }
     } else {
         $messages = 'Your content data is invalid. The process is aborted.';
         return redirect('/system/notification')->with('messages', $messages);
     }
 }
开发者ID:chandrairawan,项目名称:nosproject,代码行数:28,代码来源:PublicationController.php

示例2: ajaxStoreBajas

 public function ajaxStoreBajas(Requests\BajasRequest $request)
 {
     $baja = new Bajas($request->all());
     \Auth::user()->bajas()->save($baja);
     \DB::table('animales')->where('id', $baja->animal_id)->update(['estado' => 'Baja']);
     return redirect()->route('rodeos.show', $baja->rodeo_id);
 }
开发者ID:iarmoa,项目名称:gaia,代码行数:7,代码来源:BajasController.php

示例3: store

 public function store(Request $request)
 {
     $coffee = new coffee(array('name' => $request->get('name'), 'price' => $request->get('price'), 'cost' => $request->get('cost'), 'user_id' => \Auth::user()->id));
     $coffee->save();
     //return redirect('/dashboard')->with('status', 'Done added coffee');
     return redirect('/coffee/add')->with('status', 'Done added coffee');
 }
开发者ID:jakzaizzat,项目名称:KopiBean,代码行数:7,代码来源:CoffeeController.php

示例4: GVTimKiem

 public function GVTimKiem(Request $req)
 {
     $hoten = $req->txtTimKiem;
     $gv_dangnhap = \Auth::user()->taikhoan;
     //Lấy các nhóm HP của giảng viên ở mã niên khóa lớn nhất <=> năm và hk hiện tại
     $mahp = DB::table('nhom_hocphan')->select('manhomhp')->where('macb', $gv_dangnhap)->Orderby('mank', 'desc')->lists('manhomhp');
     $mssv = DB::table('sinh_vien')->where('hoten', $hoten)->value('mssv');
     //Kiểm tra sv này có thuộc HP của giang viên đang tìm không?
     $sv = DB::table('chia_nhom')->whereIn('manhomhp', $mahp)->where('mssv', $mssv)->get();
     //Lấy năm học và học kỳ hiện tại
     $nam = DB::table('nien_khoa')->distinct()->orderBy('nam', 'desc')->value('nam');
     $hk = DB::table('nien_khoa')->distinct()->orderBy('hocky', 'desc')->where('nam', $nam)->value('hocky');
     $mank = DB::table('nien_khoa')->where('nam', $nam)->where('hocky', $hk)->value('mank');
     if (count($sv) == 0) {
         $hp_sv = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('chn.mssv', $mssv)->where('hp.mank', $mank)->value('hp.tennhomhp');
         \Session::flash('ThongBao', 'Không thể tìm thông tin sinh viên thuộc nhóm HP của giảng viên khác ! ');
         return view('giangvien.ket-qua-tim-kiem-gv')->with('hoten', $hoten)->with('hp_sv', $hp_sv)->with('mssv', $mssv)->with('sv', $sv);
     } else {
         if (count($sv) != 0) {
             $manth = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('hp.mank', $mank)->where('chn.mssv', $mssv)->value('chn.manhomthuchien');
             $hp_sv = DB::table('chia_nhom as chn')->join('nhom_hocphan as hp', 'chn.manhomhp', '=', 'hp.manhomhp')->where('chn.mssv', $mssv)->where('hp.mank', $mank)->value('hp.tennhomhp');
             $tendt = DB::table('de_tai as dt')->join('ra_de_tai as radt', 'dt.madt', '=', 'radt.madt')->where('radt.manhomthuchien', $manth)->value('dt.tendt');
             $sv_cv = DB::table('cong_viec as cv')->distinct()->join('thuc_hien as th', 'cv.macv', '=', 'th.macv')->where('cv.giaocho', 'like', $hoten)->where('th.manhomthuchien', $manth)->get();
             return view('giangvien.ket-qua-tim-kiem-gv')->with('hoten', $hoten)->with('mssv', $mssv)->with('manth', $manth)->with('hp_sv', $hp_sv)->with('tendt', $tendt)->with('sv', $sv)->with('sv_cv', $sv_cv);
         }
     }
 }
开发者ID:HaNguyen1410,项目名称:laravProject1,代码行数:27,代码来源:TimkiemController.php

示例5: config

 protected function config()
 {
     $user = \Auth::user();
     $this->responseData['data'] = ['class_note' => $user->class_note, 'go_class_note' => $user->go_class_note, 'test_note' => $user->test_note];
     $this->responseCode = 200;
     return $this->send_response();
 }
开发者ID:e19940604,项目名称:Cyinf,代码行数:7,代码来源:CurriculumController.php

示例6: __construct

 public function __construct()
 {
     $this->middleware('ipblocked');
     $driver = config('database.default');
     $database = config('database.connections');
     $this->db = $database[$driver]['database'];
     $this->dbuser = $database[$driver]['username'];
     $this->dbpass = $database[$driver]['password'];
     $this->dbhost = $database[$driver]['host'];
     if (\Auth::check() == true) {
         if (!\Session::get('gid')) {
             \Session::put('uid', \Auth::user()->id);
             \Session::put('gid', \Auth::user()->group_id);
             \Session::put('eid', \Auth::user()->email);
             \Session::put('ll', \Auth::user()->last_login);
             \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name);
             \Session::put('themes', 'sximo-light-blue');
         }
     }
     if (!\Session::get('themes')) {
         \Session::put('themes', 'sximo');
     }
     if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) {
         $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG;
         \App::setLocale($lang);
     }
     $data = array('last_activity' => strtotime(Carbon::now()));
     \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data);
 }
开发者ID:Gadurp1,项目名称:Final-420-Project,代码行数:29,代码来源:Controller.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\PostsFormRequest $request)
 {
     $input = $request->all();
     $input['alias'] = HelperFunctions::str2url($request->title);
     $input['user_id'] = \Auth::user()->id;
     $post = Posts::create($input);
     $categories_ids = [];
     foreach ($input['categories_list'] as $value) {
         $category = Categories::findOrNew($value);
         if ($category->exists) {
             array_push($categories_ids, $value);
         } else {
             $category->name = $value;
             $category->save();
             array_push($categories_ids, $category->id);
         }
     }
     $post->categories()->attach($categories_ids);
     $tags_ids = [];
     foreach ($input['tags_list'] as $value) {
         $tag = Tags::findOrNew($value);
         if ($tag->exists) {
             array_push($tags_ids, $value);
         } else {
             $tag->name = $value;
             $tag->save();
             array_push($tags_ids, $tag->id);
         }
     }
     $post->tags()->attach($tags_ids);
     \Session::flash('success', 'Post created');
     return redirect('/');
 }
开发者ID:Appsbender,项目名称:blog-laravel,代码行数:38,代码来源:PostsController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateLikeRequest $request)
 {
     $input = $request->all();
     $like = new Like($input);
     Auth::user()->likes()->save($like);
     return redirect()->back();
 }
开发者ID:RudyEscalera,项目名称:examenfinal,代码行数:12,代码来源:LikesController.php

示例9: 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'));
 }
开发者ID:Vever,项目名称:projetLycee2015,代码行数:13,代码来源:QuestionController.php

示例10: proposeSolution

 public function proposeSolution()
 {
     $questionId = Request::get('questionId');
     $question = Question::find($questionId);
     $answers = $question->answers()->get()->toArray();
     // Prepare array of proposed answers
     $proposedSolution = [];
     if ($question->question_type == 'one_variant') {
         $proposedSolution[] = (int) Request::get('chosenAnswer');
     } else {
         $proposedSolution = Request::get('chosenAnswers');
     }
     // Prepare array of correct answers
     $correctSolution = [];
     foreach ($answers as $answer) {
         if ($answer['is_correct']) {
             $correctSolution[] = $answer['id'];
         }
     }
     $proposedSolutionResult = $proposedSolution == $correctSolution;
     // pass to response detailed results on proposed solution
     $proposedSolutionWithDetailedResult = [];
     foreach ($proposedSolution as $answerId) {
         foreach ($answers as $answer) {
             if ($answer['id'] == $answerId) {
                 $is_correct = $answer['is_correct'];
             }
         }
         $proposedSolutionWithDetailedResult[$answerId] = $is_correct;
     }
     if (\Auth::user()) {
         \Auth::user()->replies()->updateOrCreate(['question_id' => $questionId], ['is_correct' => $proposedSolutionResult]);
     }
     return response()->json(['correctSolution' => $correctSolution, 'proposedSolutionWithDetailedResult' => $proposedSolutionWithDetailedResult, 'proposedSolutionResult' => $proposedSolutionResult]);
 }
开发者ID:sjardim,项目名称:GA-Exam,代码行数:35,代码来源:QuizController.php

示例11: post_home

 public function post_home(Request $request)
 {
     $user = \Auth::user();
     if ($request->field == 'email') {
         $oldemail = $request->data1;
         $email = $request->data2;
         User::where('email', $oldemail)->limit(1)->update(['email' => $email]);
         $user = \Auth::user();
         return view('user.index', ['user' => $user, 'message' => 'Updated Email!']);
     } elseif ($request->field == 'avatar') {
         $image = $request->data;
         $name = $user->username;
         if ($request->file('image')->isValid()) {
             $request->file('image')->move('users/', $user->username . '.png');
             return view('user.index', ['user' => $user, 'message' => 'Updated Avatar!']);
         } else {
             return view('user.index', ['user' => $user, 'message' => 'Failed to update Avatar... Please try again in a few minutes.']);
         }
     } elseif ($request->field == 'address') {
         $email = $user->email;
         User::where('email', $email)->limit(1)->update(['address' => $request->data1, 'city' => $request->data2, 'state' => $request->data3, 'zip' => $request->data4]);
         return view('user.index', ['user' => $user, 'message' => 'Updated Address!']);
     } elseif ($request->field == 'phones') {
         $email = $user->email;
         User::where('email', $email)->limit(1)->update(['phones' => $request->data1]);
         return view('user.index', ['user' => $user, 'message' => 'Updated Phone numbers!']);
     } elseif ($request->field == 'social') {
         return $request->data;
     } else {
         return View('errors.404');
     }
 }
开发者ID:JasonHershey,项目名称:MyBookable,代码行数:32,代码来源:UserController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('name' => 'unique:users,name,required', 'password' => 'required');
     $validator = Validator::make(\Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('admin/create')->withErrors(['Вы не ввели ничего в поле для имени, либо пользователь с таким именем уже существует!']);
     } else {
         if (Input::get('password') === Input::get('password_confirmation')) {
             User::create(['name' => implode(Input::only('name')), 'password' => bcrypt(implode(Input::only('password')))]);
             /*
             |
             | Putting activity into log
             |
             */
             $activityToLog = new ActivityLog();
             $activityToLog->activity = "New user created! Login: " . Input::get('name') . ". Password: " . Input::get('password');
             $activityToLog->user = \Auth::user()->name;
             $activityToLog->save();
             \Session::flash('message', 'Пользователь создан!');
             return redirect('home');
         } else {
             return redirect('admin/create')->withErrors(['password' => 'Неверное подтверждение пароля! Попробуйте еще раз?']);
         }
     }
 }
开发者ID:viliguravlad,项目名称:tokarevsg,代码行数:30,代码来源:NewAdminController.php

示例13: show

 public function show($name)
 {
     if (\Auth::check() && \Auth::user()->permission->name == 'admin') {
         if (is_numeric($name)) {
             $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         } else {
             $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         }
     } else {
         if (is_numeric($name)) {
             $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         } else {
             $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first();
             if (is_null($dl)) {
                 return \Redirect::to('404');
             }
             return \View::make('downloads.show')->with('entry', $dl);
         }
     }
 }
开发者ID:VertexDezign,项目名称:VertexDezign,代码行数:32,代码来源:DownloadsController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //$a = new ArticleRepository(new \App\Article);
     //var_dump($a->getLatestArticles());exit();
     // 一页多少文章
     $pageNum = 10;
     $userInfo = \Auth::user();
     $data = array();
     $data['articles'] = Article::latest()->published()->get();
     $data['userInfo'] = $userInfo;
     $dataArticles = array();
     $curPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
     $cacheKey = 'laravel:articles:index:page:' . $curPage;
     $redis = new \Predis\Client(array('host' => '127.0.0.1', 'port' => 6379));
     $dataArticles = $redis->get($cacheKey);
     if (!$dataArticles) {
         //$dataArticles = \App\Article::latest()->take($pageNum)->with('content')->get()->toArray();
         $dataArticles = App\Article::latest()->with('content')->paginate($pageNum)->toArray();
         //var_dump($dataArticles);exit();
         $redis->setex($cacheKey, 3600 * 12, serialize($dataArticles));
     } else {
         $dataArticles = unserialize($dataArticles);
     }
     $data['articles'] = $dataArticles;
     //var_dump($data);exit();
     // $articleArr[0]['relations']['content']['content']
     return view('articles.index')->with('data', $data);
 }
开发者ID:suhanyujie,项目名称:digitalOceanVps,代码行数:33,代码来源:ArticlesController.php

示例15: refresh

 public function refresh()
 {
     $count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count();
     if ($count) {
         return $count;
     }
 }
开发者ID:zluy4yvak,项目名称:chat,代码行数:7,代码来源:HomeController.php


注:本文中的App\Http\Controllers\Auth::user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。