Php 使用供应商文件中的用户信息
您好,我有一个软件包,它将信息记录到数据库中的一个表中,我想添加正在执行该操作的用户id,即向该软件包付款。现在我的问题是,如何访问供应商文件夹中的用户id??下面是它插入的代码:Php 使用供应商文件中的用户信息,php,laravel,Php,Laravel,您好,我有一个软件包,它将信息记录到数据库中的一个表中,我想添加正在执行该操作的用户id,即向该软件包付款。现在我的问题是,如何访问供应商文件夹中的用户id??下面是它插入的代码: $this->transactionId = $this->getTable()->insert([ 'id' => $uid, 'port' => $this->getPortName(),
$this->transactionId = $this->getTable()->insert([
'id' => $uid,
'port' => $this->getPortName(),
'price' => $this->amount,
'status' => Enum::TRANSACTION_INIT,
'ip' => Request::getClientIp(),
'description' => $this->description,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]) ? $uid : null;
您可以通过Auth facade访问经过身份验证的用户:
您可以通过Illumb\Http\请求访问经过身份验证的用户
通过Auth helper函数:
在供应商文件夹中是什么意思?
use Illuminate\Support\Facades\Auth;
// Get the currently authenticated user...
$user = Auth::user();
// Get the currently authenticated user's ID...
$id = Auth::id();
use Illuminate\Http\Request;
public function someFunctionName(Request $request)
{
$request->user(); //returns an instance of the authenticated user...
$request->user()->id; // returns authenticated user id.
}
auth()->user(); //returns an instance of the authenticated user...
auth()->user()->id ; // returns authenticated user id.