本文整理汇总了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.");
}
示例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;
}
}
}
示例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);
}
示例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');
}
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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()]);
}
示例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);
}
示例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);
}
示例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.');
}
示例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]);
}
示例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();
}
示例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');
}
}