本文整理汇总了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);
}
}
示例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);
}
示例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');
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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('/');
}
示例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();
}
示例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'));
}
示例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]);
}
示例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');
}
}
示例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' => 'Неверное подтверждение пароля! Попробуйте еще раз?']);
}
}
}
示例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);
}
}
}
示例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);
}
示例15: refresh
public function refresh()
{
$count = Message::where('id_receive', \Auth::user()->id)->where('read', NULL)->count();
if ($count) {
return $count;
}
}