本文整理汇总了PHP中auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::user方法的具体用法?PHP auth::user怎么用?PHP auth::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth
的用法示例。
在下文中一共展示了auth::user方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (!Auth::check()) {
return view('account.login');
}
$orders = auth::user()->orders()->with('Items', 'Items.Product', 'Items.Product.images')->orderBy('created_at', 'asc')->limit(3)->get();
return view('account.account', compact('orders'));
}
示例2: buy
public function buy($id)
{
if (Useradd::where('user_id', '=', Auth::user()->id)->first()) {
$product = Product::find($id);
$quantity = Input::get("quantity");
if (intval($quantity) < $product->stock) {
$name = $product->name;
$price = intval($product->price);
$tax = intval($product->price) * 0.2;
$fdp = 4.0;
$total = (intval($product->price) + $tax) * intval($quantity) + $fdp;
$user = "romario.dev_api1.gmail.com";
$password = "TAKKCTMU7337MNEM";
$signature = "AoGYbXCKniGwhG49iNKxRHnnmLrYAFTKM07RzfsOtBl3ppaYNM3k0CEj";
$params = array('METHOD' => 'SetExpressCheckout', 'VERSION' => '93', 'USER' => $user, 'SIGNATURE' => $signature, 'PWD' => $password, 'RETURNURL' => "http://dcmstore.io/paypal/success", 'CANCELURL' => "http://dcmstore.io/paypal/error", 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', 'L_PAYMENTREQUEST_0_NAME0' => $name, 'L_PAYMENTREQUEST_0_AMT0' => strval($price), 'L_PAYMENTREQUEST_0_QTY0' => $quantity, 'PAYMENTREQUEST_0_ITEMAMT' => strval($price * intval($quantity)), 'PAYMENTREQUEST_0_TAXAMT' => strval($tax * $quantity), 'PAYMENTREQUEST_0_SHIPPINGAMT' => strval($fdp), 'PAYMENTREQUEST_0_HANDLINGAMT' => '0.00', 'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00', 'PAYMENTREQUEST_0_INSURANCEAMT' => '0.00', 'PAYMENTREQUEST_0_AMT' => strval($total), 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'ALLOWNOTE' => '1');
$params = http_build_query($params);
$endpoint = 'https://api-3T.sandbox.paypal.com/nvp';
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_URL => $endpoint, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $params, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_VERBOSE => 1));
$response = curl_exec($curl);
$responseArray = array();
parse_str($response, $responseArray);
curl_close($curl);
if ($responseArray['ACK'] == 'Success') {
$user = Useradd::where('user_id', '=', Auth::user()->id)->first();
$order_id = Order::insertGetId(array('user_id' => auth::user()->id, 'date' => \Carbon\Carbon::now(), 'price' => $total, 'add_id' => $user->id, 'rcp_id' => $user->id, 'note' => 'null', 'status' => 0, 'token' => $responseArray['TOKEN']));
$oders_items = Orderitem::create(array('order_id' => $order_id, 'item_id' => $id, 'item_qt' => $quantity, 'unit_price' => $price));
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $responseArray['TOKEN'];
return Redirect::to($url);
}
} else {
return Redirect::to('product/' . $id)->with('message', 'Stock insuffisant');
}
} else {
return Redirect::to('product/' . $id)->with('message', 'Veuillez renseigner une addresse dans le dashboard!');
}
}
示例3: index
public function index()
{
$user = auth::user();
$activeAuctions = $user->getActiveAuctions();
return view('profile', compact('user', 'activeAuctions'));
}
示例4: function
if ($url != URL::to('/') . "/register") {
return Redirect::to('register');
}
}
});
Route::filter('statusCheck', function () {
$userstatus = auth::user()->userstatus;
if ($userstatus == 'pending' || $userstatus == 'fetching connection' || $userstatus == 'ready for approval' || $userstatus == 'hidden') {
return Redirect::to('status');
}
if ($userstatus == 'TOS not accepted') {
Redirect::to('register');
}
});
Route::filter('AdminCheck', function () {
$userrole = auth::user()->role;
if ($userrole != 'admin') {
return Redirect::to('/dashboard');
}
});
Route::filter('GroupCheck', function ($route) {
$Giver_id = Route::input('Giver');
$giverdetail = User::find($Giver_id);
if ($giverdetail->meeting_setting != 'accept from all') {
$ReceiverGroupDetail = Auth::User()->Groups;
$giverGroupDetail = User::find($Giver_id)->Groups;
foreach ($giverGroupDetail as $key => $valueGiver) {
foreach ($ReceiverGroupDetail as $key => $valueReceiver) {
if ($valueReceiver->id == 1) {
return;
}
示例5: statusCheck
public function statusCheck()
{
$CurrentUser = Auth::User();
$userstatus = auth::user()->userstatus;
if ($userstatus == 'pending' || $userstatus == 'fetching connection' || $userstatus == 'ready for approval') {
return View::make('error/pending', array('CurrentUser' => $CurrentUser));
} elseif ($userstatus == 'hidden') {
return View::make('error/hidden', array('CurrentUser' => $CurrentUser));
} else {
return Redirect::to('/dashboard');
}
}
示例6: doLogin
public function doLogin()
{
$email = Input::get('email');
$password = Input::get('password');
if (Auth::attempt(array('email' => $email, 'password' => $password))) {
if (Auth::user()->is_helper == TRUE) {
return Redirect::intended(action('UsersController@dashboard_helper', auth::user()->id));
} elseif (Auth::user()->is_helper == FALSE) {
return Redirect::intended(action('UsersController@dashboard_creator', auth::user()->id));
}
} else {
Session::flash('errorMessage', 'Email or Password not found.');
return Redirect::action('HomeController@showLogin')->withInput();
}
}
示例7: GuardarVenta
private function GuardarVenta($datos, $suma)
{
$Lista = array();
$Venta = Venta::create(['id_usuario' => auth::user()->id, 'fecha_compra' => Carbon::now(), 'total' => $suma]);
foreach ($datos as $ID => $Valor) {
$vcp = Venta_cuerpo::create(['id_cabecera' => $Venta->id, 'id_producto' => $ID, 'cantidad' => $Valor['cantidad'], 'precio_unitario' => $Valor['precio']]);
$vcp->save();
$pro = Producto::findOrFail($ID);
$stock = $pro->stock();
$stock->cantidad -= $Valor['cantidad'];
$stock->save();
$Lista[$ID]['nombre'] = $pro->nombre;
$Lista[$ID]['cantidad'] = $Valor['cantidad'];
$Lista[$ID]['precio'] = $Valor['precio'];
}
$Venta->save();
$this->sendMailCompra($Venta, $Lista);
}
示例8:
<tr>
<td><?php
echo $value['ni'];
?>
</td>
<td><?php
echo $value['nome'];
?>
</td>
<td> <?php
echo $value['acesso'];
?>
</td>
<?php
if (Auth::user() !== null && auth::user()->acesso == 'adm') {
?>
<td>
<a href="<?php
echo URL::to('/');
?>
/usuario/<?php
echo $value['ni'];
?>
/edit" class="btn btn-xs btn-primary" >
<i class="glyphicon glyphicon-pencil"></i> Editar <span class="ripple-wrapper"></span>
</a>
<a href="<?php
echo URL::to('/usuario/delete/' . $value['ni']);
示例9: __construct
public function __construct()
{
view()->share('user', auth::user());
}
示例10: _init
public static function _init()
{
if(strpos(self::$class,"\\")!==false)
{
$cl=explode("\\",self::$class);
self::$class=$cl[count($cl)-1];
}
self::$c=_a::core();
self::$silent=self::$c->silent();
self::$uid=auth::user("id");
//читаем сессию
self::_sessionRead();
if(isset(self::$session["files"]))
{
self::$files=self::$session["files"];
if(!is_array(self::$files))self::$files=array();
}
//проверяем поддерживаемые типы
$types=imagetypes();
if($types & IMG_GIF)self::$imgSup[]=MEDIA_IMG_GIF;
if($types & IMG_JPG)self::$imgSup[]=MEDIA_IMG_JPG;
if($types & IMG_PNG)self::$imgSup[]=MEDIA_IMG_PNG;
if($types & IMG_WBMP)self::$imgSup[]=MEDIA_IMG_WBMP;
if($types & IMG_XPM)self::$imgSup[]=MEDIA_IMG_XBM;
if(!in_array(self::$config["imgTypeDefault"],self::$imgSup))
{
if(count(self::$imgSup))self::$config["imgTypeDefault"]=self::$imgSup[0];
else
{
msgr::add("Критическая ошибка ядра [".self::$class."]: не удалось определить поддерживаемые типы изображений!");
return;
}
}
}
示例11: update
public static function update($filters=array(),$values=array(),$data=false)
{
$sl=self::$c->silent();
$uid=auth::user("id");
if(!is_string($data) || !$data)$data=false;
$t=db::tMeta("content");
$fs=array_keys($t);
//проверяем фильтры
$fts=array();
$filterId=-1;
foreach($filters as $filter)
{
if(is_string($filter))
{
$t=str_replace("`","",$filter);
$t=preg_replace("/\s+/","",$t);
if(strpos($filter,"id=")!==false)
{
$id=str_replace("id=","",$t);
if(($id && ((0+$id)>0)))$filterId=$id;
else continue;
}
$fts[]=$filter;
continue;
}
if(is_array($filter))
{
if(isset($filter[0]) && (in_array($filter[0],$fs)) && isset($filter[1]) && isset($filter[2]))
{
if(($t[$filter[0]]["type"]=="string") || ($t[$filter[0]]["type"]=="text"))
{
$filter[2]="".$filter[2];
$type="string";
}
else $type="other";
$fts[]=array($type,$filter[2],"AND",$filter[0],$filter[1]);
if(($filter[0]=="id") && ($filter[1]=="=") && ($filter[2]>0))$filterId=$filter[2];
}
}
}
//проверяем данные
$dts=array();
$actInProc=false;
$aliasInProc=false;
foreach($values as $field=>$value)
{
if(!is_string($field))continue;
if(!in_array($field,$fs))continue;
if(in_array($field,self::$fieldsSys))continue;
if($field=="act")$actInProc=true;
if($field=="alias")$aliasInProc=true;
if(($t[$field]["type"]=="string") || ($t[$field]["type"]=="text"))
{
$value="".$value;
$type="string";
}
else $type="other";
$dts[]=array($type,$value,",",$field,($value===false?"NOT":"="));
}
if(!count($dts))
{
$msg="Невозможно выполнить операцию: данные не распознаны или заданы с ошибкой.";
msgr::errorLog($msg,true,self::$class,__FUNCTION__,__LINE__,"Input values: ".serialize($values).", parced data: ".serialize($dts));
return false;
}
$fc=count($fts);
if(count($filters)!=$fc)
{
$msg="Невозможно выполнить операцию: один или несколько критериев поиска не распознаны или заданы с ошибкой.";
msgr::errorLog($msg,true,self::$class,__FUNCTION__,__LINE__,"Input filters: ".serialize($filters).", parced filters: ".serialize($fts));
return false;
}
if($data && (($filterId==-1) || ($fc!=1)))
{
$data=false;
if(!$sl)msgr::add("Содержимое страницы проигнорировано: фильтр должен содержать только указатель на конкретную страницу.",MSGR_TYPE_WRN);
}
$dts=db::filtersMake($dts,true,true,false);
$fts=db::filtersMake($fts,true,true,false);
//кол-во затрагиваемых страниц
$r=db::q("SELECT COUNT(`id`) AS `cnt` FROM ".db::tnm(self::$class).($fts?(" WHERE ".$fts):""),!$sl);
if($r===false)return false;
$rec=mysql_fetch_row($r);
$affected=0+$rec[0];
if(!$affected)
{
$msg="Выборка набор страниц по заданному фильтру не принесла результата.";
msgr::errorLog($msg,true,self::$class,__FUNCTION__,__LINE__,"Input filters: ".serialize($filters).", joined filters: [".$fts."]");
return false;
}
if($aliasInProc)
{
if(!self::check("alias",$values["alias"],0,false))return false;
//проверка установки алиаса для более чем 1 страницы
if($affected>1)
{
$msg="Невозможно выполнить операцию: попытка задать одинаковый алиас для множества страниц.";
msgr::errorLog($msg,true,self::$class,__FUNCTION__,__LINE__,"Input filters: ".serialize($filters).", joined filters: [".$fts."]");
return false;
}
//.........这里部分代码省略.........
示例12:
<h4>Last name</h4>
<p>{{{ $user->last_name }}}</p>
</div>
</div>
</div>
<div>
<div class="row">
<div class="col-md-6 side-hr">
<h4>Email</h4>
<p>{{{ $user->email }}}</p>
</div>
<div class="col-sm-6">
<?php
if (auth::user()->is_helper == 0) {
?>
<h4>Age</h4>
{{{ $user->birth_date->age }}}
<?php
} else {
?>
<h4>Age</h4>
{{{ $user->birth_date->age }}}
<?php
}
?>
</div>
</div>
</div>
示例13: postPerfil
public function postPerfil(Request $request)
{
switch ($request->input('get')) {
case 'edit':
$user = User::find(Auth::User()->id);
$user->name = $request->input("name");
$user->lastname = $request->input("lastname");
$user->email = $request->input("email");
echo $user->save() ? "true" : "false";
break;
case 'createService':
$categorias = '[]';
if ($request->input('category') != "") {
$categorias = json_encode($request->input('category'));
}
$servicio = new Servicio();
$servicio->user_id = auth::user()->id;
$servicio->name = $request->input('name');
$servicio->description = $request->input('description');
$servicio->busco = $request->input('busco');
$servicio->state = "inactive";
$servicio->puntos = (int) $request->input('puntos');
$servicio->categorias = $categorias;
echo $servicio->save() ? "true" : "false";
break;
case 'getServices':
$services = User::find(Auth::User()->id)->services->toArray();
$formatted = array();
$categorias = Categoria::all()->toArray();
foreach ($services as $k => $v) {
$catFomart = array();
$cat = json_decode($v['categorias']);
foreach ($categorias as $kc => $vc) {
$catFomart[$kc]['name'] = $vc['name'];
$catFomart[$kc]['id'] = $vc['id'];
if (in_array($vc['id'], $cat)) {
$catFomart[$kc]['selected'] = true;
} else {
$catFomart[$kc]['selected'] = false;
}
}
$services[$k]['categorias'] = $catFomart;
}
echo json_encode(array_reverse($services));
break;
case 'deleteService':
$id = $request->input('id');
$service = Servicio::find($id);
echo $service->delete() ? 'true' : 'false';
break;
case 'activeService':
$id = $request->input('id');
$service = Servicio::find($id);
$service->state = "active";
echo $service->save() ? 'true' : 'false';
break;
case 'deactivatedService':
$id = $request->input('id');
$service = Servicio::find($id);
$service->state = "inactive";
echo $service->save() ? 'true' : 'false';
break;
case 'saveService':
$categorias = array();
foreach ($request->input('categorias') as $k => $v) {
if ($v['selected']) {
array_push($categorias, $v['id']);
}
}
$servicio = Servicio::find($request->input('id'));
$servicio->name = $request->input('name');
$servicio->description = $request->input('description');
$servicio->busco = $request->input('busco');
$servicio->puntos = (int) $request->input('puntos');
$servicio->categorias = json_encode($categorias);
echo $servicio->save() ? 'true' : 'false';
break;
default:
# code...
break;
}
}