当前位置: 首页>>代码示例>>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;未经允许,请勿转载。