本文整理汇总了PHP中Illuminate\Support\Facades\Auth::Id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::Id方法的具体用法?PHP Auth::Id怎么用?PHP Auth::Id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::Id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postImages
/**
* @param Request $request
* @return string
*/
public function postImages(Request $request)
{
$response = array();
$root = 'uploads/';
$savePath = $root . Auth::Id() . "/" . date('Y_m') . "/" . date('d');
if ($request->hasFile('file')) {
$image = $request->file('file');
if ($image->isValid()) {
$extension = $image->getClientOriginalExtension();
$file_name = str_random(3) . time() . '.' . $extension;
$image->move($savePath, $file_name);
$response['status'] = true;
$response['code'] = 200;
$response['message'] = 'File uploaded successfully';
$response['file_path'] = $savePath . "/" . $file_name;
$response['file_name'] = $file_name;
} else {
$response['status'] = false;
$response['code'] = 500;
$response['message'] = 'Something went wrong while Uploading';
$response['file_path'] = false;
$response['file_name'] = false;
}
} else {
$response['status'] = false;
$response['code'] = 404;
$response['message'] = 'No image uploaded';
$response['file_path'] = false;
$response['file_name'] = false;
}
return json_encode($response);
}