草庐IT

user_passes_test

全部标签

php - 如何在 Laravel 中向 Auth::user() 添加自定义值

我有一些自定义值,我想在用户登录时在整个项目中使用。我正在Controller中编写一个函数,但每次调用该静态方法会使代码有点冗长。我不想调用函数,而是想为Auth::user()分配一个自定义值,这样我就可以在项目的任何地方使用它。我在下面的代码中尝试过,但它不起作用publicstaticfunctiongetUserDetailById($id){//DoSomethingandassignvalueto$custom_valAuth::user()->custom=$custom_val;}但它在任何Controller或View中都不起作用。我试图检查Auth::user()

php - "Type error: Too few arguments to function App\Http\Controllers\UserController::attendance(), 0 passed and exactly 1 expected"

我的数据库中有两个表,分别是用户表和出勤表。我现在想做的是根据用户在与他们的个人资料相关联的出勤View中显示数据库中的出勤数据。这是我在userController中的考勤功能。publicfunctionattendance($id){$user=UserProfile::findOrFail($id);$this->authorize('modifyUser',$user);returnview('user.attendance',['user'=>$user]);}这是我到出勤View的路径。Route::get('/attendance/',['as'=>'user.atte

php - Facebook 图谱 API v2.1 : getting user id and his posts

想象一下当我以userA身份登录facebookweb应用程序时的情况。我知道userB的昵称,但他不在我的好友列表中,我也不知道他的ID。当然,他不使用我的应用程序。如何通过昵称获取用户B的ID?之后我怎样才能得到他的墙贴?是否有任何特定权限?可能有我遗漏的手册页? 最佳答案 在v1.0中,以下是可能的:http://graph.facebook.com/v1.0/{user-name}但是,对于v2.0和v2.1,无法通过未连接到您的应用程序的ID或用户名访问用户。例如,尝试http://graph.facebook.com/v

php - 在 php 中启用 user_birthday 权限 facebook 生日

我正在制作一个facebook应用程序来显示用户的生日.........'YOUR_APP_ID','secret'=>'YOUR_APP_SECRET',);$facebook=newFacebook($config);$user_id=$facebook->getUser();?>api('/me','GET');echo"Name:".$user_profile['name'];//BirthDatetobeprintedhere........echo"DOB:".$user_profile['birthday'];}catch(FacebookApiException$e){

java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using password: YES)报错原因

1.第一个:用户名和密码不匹配,或者是在连接池里多打了空格之类的就是配置文件的问题;2.第二个:可能是用户的权限不够,给他添加权限;授予权限--grantallprivilegesondatabasename.tablenameto'user'@'host'identifiedby'password';--授予myuser用户全局级全部权限:GRANTALLPRIVILEGESON*.*TO'myuser'@'%'IDENTIFIEDBY'mypass'WITHGRANTOPTION;--授予myuser用户针对testdb数据库全部权限:GRANTALLPRIVILEGESONtestdb.

php - 微信: OAuth with test account

实际上,我正在尝试使用微信为我的Web应用程序设置OAuth登录。所以,我在微信上创建了一个帐户,并使用了一个测试帐户来无限访问。因此,在测试帐户配置中,我已成功验证来自微信的token(参见此处:http://admin.wechat.com/wiki/index.php?title=Getting_Started)。在文档中,OAuth在这里解释:http://admin.wechat.com/wiki/index.php?title=User_Profile_via_Web我们必须将用户重定向到此URL进行登录:https://open.weixin.qq.com/connect

php - Facebook FQL 用户表 `sex` 字段 : how to return male/female even the user is using different locale?

情况:我的facebook应用程序(http://apps.facebook.com/mymagicmirror/)需要检测用户的性别,然后查询异性或男性或女性FQL:SELECTuid,name,pic,sexFROMuserWHEREuidIN(SELECTuid2FROMfriendWHEREuid1='.$user_id.')andsex='male'问题:当facebook用户使用其他语言环境时,“性别”字段不再匹配“男性”和“女性”。相反,用中文来说,性别将变为男性/女性,而sex='male'的FQL将返回零结果。有什么解决方案可以查询所有男性/女性friend,即使fa

PHP 教义 : Test if an object is in an ArrayCollection

我正在尝试使用方法ArrayCollection::contains来查找对象是否已经在我的集合中,但是当我这样做时://MyArrayCollection$lesRoles=$drt->getDrtApplication()->getRoles();$leRole=$lesRoles->first();echo"PropertyappNom:".$leRole->getRleApplication()->getAppNom()."//PropertyappRole:".$leRole->getRleId()."";$role=new\Casgaya\Role(2,$drt->getD

php - Mac 上的 Valet : 502 bad gateway when running test. dev,laravel,php 安装

我在mac上用fpm在本地安装了php71。然后在去“pinganyting.dev”时让代客工作。然后进入“PHP_Apps”目录,我在其中安装了所有PHP应用程序,并在该目录中运行“代客泊车”。我在其中创建了一个包含index.php文件的“测试”目录。在浏览器中转到index.dev显示:502BadGatewaynginx/1.10.2还有日志文件记录:2017/01/3116:58:48[crit]285#0:*16connect()tounix:/Users/ME/.valet/valet.sockfailed(2:Nosuchfileordirectory)whileco

php - 拉维尔 5.4 : Get logged in user id inside __construct()

我试图在构造函数中访问Auth::user()->id;但它总是返回错误Tryingtogetpropertyofnon-object。我在laravel文档中研究了Session在构造函数内部不可访问,并且还在SO上搜索了这个。我需要在构造函数中登录用户ID,因为我必须从数据库中获取数据并使其可用于所有方法。我当前的代码是:publicfunction__construct(){$this->middleware('auth');$induction_status=TrainingStatusRecord::where('user_id',Auth::user()->id)->whe