當前位置: 首頁>>代碼示例>>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: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateBookRequest $request)
 {
     $user = \Auth::User();
     if (!$user) {
         return view('auth.login')->withErrors('You are not loged in, please loged in !');
     }
     $book = $request->bookFillData();
     $book['user_id'] = $user->id;
     $book['published_at'] = Carbon::parse($request->get('published_at'))->format('Y-m-d');
     $fileSizeValidation = \Config::get('library.image_file_size');
     $newBook = Book::create($book);
     $newBook->syncAuthors($request->get('authors'));
     $this->manager->createDirectory($newBook->id);
     $file = $_FILES['image'];
     if ($file['size'] > 0) {
         // Additional image validation
         if (!starts_with($file['type'], 'image/')) {
             return Redirect::action('BookController@create')->withErrors('Invalid file format, please use image !');
         }
         $fileSize = $file['size'] / 1024;
         if ($fileSize > $fileSizeValidation) {
             return Redirect::action('BookController@create')->withErrors('The image may not be greater than ' . $fileSizeValidation . ' kilobytes. ');
         }
         $img = Image::make($_FILES['image']['tmp_name']);
         $img->resize(140, 140);
         $img->save('.' . \Config::get('library.uploads.webpath') . DIRECTORY_SEPARATOR . $newBook->id . '/cover.jpg');
     }
     return redirect::action('BookController@index')->withSuccess("The book with title '{$newBook->title}' was created.");
 }
開發者ID:EmilAleksandrov,項目名稱:book-library-laravel,代碼行數:35,代碼來源:BookController.php

示例2: actualizar

 public function actualizar(Request $request)
 {
     if ($request->ajax()) {
         $email = $request['email'];
         $password = $request['password'];
         $new_password = $request['new_password'];
         $user = \Auth::User();
         $updated = false;
         if (Hash::check($password, $user->password)) {
             $aux = \App\User::find($email);
             if ($aux == null || $aux->email == $user->email) {
                 $user->email = $email;
                 $updated = true;
             } else {
                 return -2;
             }
             if ($new_password != '') {
                 $user->password = bcrypt($new_password);
             }
             $user->save();
             return 1;
         } else {
             return -1;
         }
     }
 }
開發者ID:Lespoir,項目名稱:belltroniceu,代碼行數:26,代碼來源:UserController.php

示例3: __construct

 public function __construct()
 {
     $objUser = \Auth::User() ?: \App\User::GetGuestAccount();
     View::share('CareerCount', \App\Career::where('status', \App\Career::STATUS_ENABLED)->count());
     View::share('PageTitle', 'Welcome');
     View::share('objUser', $objUser);
 }
開發者ID:electronbabies,項目名稱:JVE,代碼行數:7,代碼來源:StaticController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $name = $request->input('name');
     $artist = $request->input('artist');
     $type = 1;
     $view;
     if (\Auth::check()) {
         if (\Auth::User()->roll == "Administrador") {
             $view = 'songs.index';
         } else {
             if (\Auth::User()->roll == "Cliente") {
                 $view = 'songs.songs_user';
             }
         }
         if ($name == null && $artist == null) {
             $songs = Song::getsongs();
             return view($view, compact('songs'));
         } else {
             if ($name != null && $artist == null) {
                 $songs = \App\Models\Song::search_by_song($name, $type);
                 return view($view, compact('songs'));
             } else {
                 if ($name == null && $artist != null) {
                     $songs = \App\Models\Song::search_by_singer($artist);
                     return view($view, compact('songs'));
                 } else {
                     $songs = \App\Models\Song::search_by_singer_song($name, $artist);
                     return view($view, compact('songs'));
                 }
             }
         }
     } else {
         return view('auth.login');
     }
 }
開發者ID:pumba3211,項目名稱:PHP,代碼行數:40,代碼來源:SongController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\EmployeeRequest $request)
 {
     //
     $data = $request->except('_token');
     $data['user_id'] = \Auth::User()->id;
     $employee = new Employee();
     $employee->create($data);
     return back();
 }
開發者ID:sunhuang2015,項目名稱:mytask,代碼行數:15,代碼來源:EmployeeController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $traslado = new Traslados($request->all());
     \Auth::User()->traslados()->save($traslado);
     foreach ($data['animales'] as $i => $animal) {
         $traslado->animales()->attach($animal);
     }
     return redirect()->route('traslados.show', $traslado->id);
 }
開發者ID:iarmoa,項目名稱:gaia,代碼行數:16,代碼來源:TrasladosController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $compras = new Compras($request->all());
     \Auth::User()->compras()->save($compras);
     foreach ($data['insumos'] as $i => $insumo) {
         \DB::table('compras_insumos')->insertGetId(array('compra_id' => $compras->id, 'insumo_id' => $insumo['insumo_id'], 'precio' => $insumo['precio'], 'cantidad' => $insumo['cantidad'], 'almacen_id' => $insumo['almacen']));
     }
     return redirect()->route('compras.show', $compras->id);
 }
開發者ID:iarmoa,項目名稱:gaia,代碼行數:16,代碼來源:ComprasController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $compras = new Compras($request->all());
     \Auth::User()->comprasinsumos()->save($compras);
     foreach ($data['insumos'] as $i => $insumo) {
         $compras->insumos()->attach($insumo);
     }
     return redirect()->route('comprasinsumos.show', $compras->id);
 }
開發者ID:iarmoa,項目名稱:gaia,代碼行數:16,代碼來源:ComprasInsumosController.old.php

示例9: index

 public function index()
 {
     $ranks = \App\Ranking::all();
     foreach ($ranks as $rank) {
         if ($ranks->count() >= $rank->id * 2 * 2 + 3) {
             $rank->slot_exit = 1;
             $rank->save();
         }
     }
     return view('dashboard.admin.rank')->with(['ranks' => $ranks, 'user' => \Auth::User()]);
 }
開發者ID:arkivalenciaii,項目名稱:clientv2,代碼行數:11,代碼來源:RankController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $servicio = new Servicios($request->all());
     \Auth::User()->servicios()->save($servicio);
     foreach ($data['animales'] as $d) {
         $id = \DB::table('servicios_potreros')->insertGetId(array('animal_id' => $d['animal_id'], 'potrero_origen_id' => $d['potrero_origen_id'], 'servicio_id' => $servicio->id));
         \DB::table('animales')->where('id', $d['animal_id'])->update(['potrero_id' => $servicio['potrero_id']]);
     }
     return redirect()->route('servicios.show', $servicio->id);
 }
開發者ID:iarmoa,項目名稱:gaia,代碼行數:17,代碼來源:ServiciosController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $movimiento = new Movimientos($request->all());
     \Auth::User()->movimientos()->save($movimiento);
     //print_r($data); die();
     foreach ($data['pivot'] as $d) {
         $id = \DB::table('movimientos_animales')->insertGetId(array('animal_id' => $d['animal_id'], 'potrero_origen_id' => $d['potrero_origen_id'], 'potrero_destino_id' => $d['potrero_destino_id'], 'movimiento_id' => $movimiento->id));
         \DB::table('animales')->where('id', $d['animal_id'])->update(['potrero_id' => $d['potrero_destino_id']]);
     }
     return redirect()->route('movimientos.show', $movimiento->id);
 }
開發者ID:iarmoa,項目名稱:gaia,代碼行數:18,代碼來源:MovimientosController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param Requests\VaccineDoseRequest $request
  * @return Response
  */
 public function store(Requests\VaccineDoseRequest $request)
 {
     $input = $request->all();
     $vaccine_id = $input['vaccine_id'];
     for ($i = 0; $i < count($input['dose_no']); $i++) {
         $data['dose_vaccine_id'] = $vaccine_id;
         $data['dose_vaccine_dose_no'] = $input['dose_no'][$i];
         $data['years'] = $input['years'][$i];
         $data['months'] = $input['months'][$i];
         $data['days'] = $input['days'][$i];
         $data['dose_interval'] = $input['years'][$i] * 365 + $input['months'][$i] * 30 + $input['days'][$i];
         $data['created_by'] = \Auth::User()->id;
         $data['updated_by'] = \Auth::User()->id;
         $this->vaccineDose->create($data);
     }
     return redirect('vaccines')->with('message', 'Vaccine dose interval is assigned.');
 }
開發者ID:ashokadhikari92,項目名稱:NCDB_Final,代碼行數:23,代碼來源:VaccineDoseController.php

示例13: create

 public function create()
 {
     $num_slots = \Input::get('num_slots');
     $check = \Auth::User()->name . '' . Carbon::now();
     for ($i = 0; $i < $num_slots; $i++) {
         $slot = new \App\Slot();
         $slot->slot_code = bcrypt($check);
         $slot->slot_rank = 0;
         $slot->user_id = \Auth::User()->id;
         $slot->save();
         $status = \App\Status::find(2);
         $status->slots()->attach($slot);
     }
     $user = \Auth::User();
     $name = $user->name;
     $slots = $user->slots()->get();
     return view('dashboard.user.profile')->with(['slots' => $slots, 'name' => $name, 'num_slots' => $num_slots]);
 }
開發者ID:arkivalenciaii,項目名稱:laravel5-default,代碼行數:18,代碼來源:DashboardController.php

示例14: show

 /**
  * get notification
  *
  * default => the newset 10
  *
  * @param Request $request
  * @return Response
  */
 protected function show(Request $request)
 {
     $user = \Auth::User();
     if ($this->vaild_data_format($request->all(), ['range', 'item_id']) === true) {
         $item_id = $request->get("item_id");
         $range = $request->get("range");
         if ($range > 0) {
             $notis = $this->notificationRepository->getNotificationBack($user->stu_id, $item_id, $range);
         } else {
             $notis = $this->notificationRepository->getNotificationFront($user->stu_id, $item_id, $range * -1);
         }
     } else {
         $notis = $this->notificationRepository->getLatest10Notification($user->stu_id);
     }
     $this->responseData['status'] = "success";
     $this->responseData['data'] = NotificationPresenter::db2api($notis->toArray());
     $this->responseCode = 200;
     return $this->send_response();
 }
開發者ID:e19940604,項目名稱:Cyinf,代碼行數:27,代碼來源:NotificationController.php

示例15: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     if (\Auth::user()) {
         $order = \Auth::User()->orders();
         $ids = null;
         if ($order) {
             $orders = Orders::where('cust_id', \Auth::User()->id)->get();
         }
         $orders = Orders::where('cust_id', \Auth::User()->id)->where('order_id', $id)->get();
         $i = 0;
         foreach ($orders as $order) {
             $order['p_name'] = Products::where('id', $order->product_id)->value('p_name');
             $order['price'] = Products::where('id', $order->product_id)->value('price');
             $ids[$order['product_id']] = $order['product_id'];
         }
         return view('pages.order', compact('orders'), compact('ids'));
     } else {
         return redirect('auth/login');
     }
 }
開發者ID:knowhere1998,項目名稱:inventory-management,代碼行數:26,代碼來源:OrdersController.php


注:本文中的App\Http\Controllers\Auth::User方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。