草庐IT

laravel-socialite

全部标签

php - Laravel 5.3 密码授予 token [用户凭据不正确]

使用vagrant/homestead设置Laravel5.3Passport。一直跟着我到达PasswordGrantTokens在这里,我发现了这个GuzzleHttp片段,可以发布到/oath/token:Route::get('/api_grant',function(){$http=newGuzzleHttp\Client;$response=$http->post('http://mavrik-cms.io/oauth/token',['form_params'=>['grant_type'=>'password','client_id'=>'6','client_secr

php - Laravel 查询生成器不使用 get 方法中的变量

我的一个Controller中有这个功能。publicfunctiontourList($country,$category){$tour=Tour::whereHas('country',function($q){$q->where('name','=',$country);})->whereHas('category',function($r){$r->where('name','=',$category);})->get();returnview('tour-list.blade.php')->withTour('$tour');}虽然已经从get方法传递了两个变量。但是我收到错

php - 无法访问 Auth::check 我在 laravel 5.3 中的 View

我是laravel框架的新手,正在尝试在我的网站上实现登录系统。我的网站有一个登陆页面。根据用户登录状态,我需要像下面这样更改此链接。@if(Auth::guard('customer')->check())Logout@elseLoginorRegister@endif这是负责加载这个View的Controller我收到一条错误消息说Class'Auth'notfound我尝试添加useAuth和use\Auth按照stackoverflow中其他更复杂的问题的建议,但对我不起作用。我究竟做错了什么。无法从View中检查调用Auth吗? 最佳答案

php - 更改 Laravel TokenGuard 存储 key

我正在尝试使用apitoken实现新的Laravel5.3auth:apimiddleware。因为我已经有一个包含“ApiToken”字段的旧用户表,所以我想将TokenGuardstorageKey属性(可能还有inputKey)更改为“ApiToken”而不是“api_token”。类似于getRememberTokenName方法,但是我找不到“getApiTokenName”方法。有没有一种方法可以在不更改LaravelTokenGuard源代码的情况下完成此操作? 最佳答案 您不能覆盖TokenGuard类中的stora

php - undefined offset : 0 in laravel

我的框架是Laravel5.2,数据库里没有记录。但是在这个站点中,它有错误。错误是:ErrorExceptioninCollection.phpline1187:Undefinedoffset:0Controller是:publicfunctionindex(){$comment=ProviderComment::GetComments($ID);return$comment;}模型是:publicfunctionscopeGetComments($query,$vendorID){$join=$query->join('couples','couples.id','=','prov

php - Laravel auth 中间件使用了错误的数据库

在config/database.php中,我有两个连接:mysql和website。两者都连接到同一台主机,只是数据库不同。默认为mysql。我创建了一个名为SetupWebsite的中间件,它检查传入域是否存在于默认连接的数据库中。如果是,它会使用以下代码用正确的数据库填充website连接:config(['database.connections.website.database'=>$database]);然后,它将默认连接切换到网站:config(['database.default'=>'website']);我通过从数据库中检索一个仅存在于website连接中的值来验证

php - Laravel setter 注入(inject)

我如何在Laravel的服务容器中使用setter依赖注入(inject)来实现自动依赖解析?这是一个例子:classTest{(...)publicfunctionsetMailer(Mailer$mailer){$this->mailer=$mailer;}(...)functionsendEmail(){$this->mailer->send(newEmail('john.doe@example.com'));}}我如何确保在调用sendEmail()时,邮件程序依赖性得到统计?我如何利用Laravel的服务容器来实现这一目标?提前致谢。 最佳答案

php - 如何为 laravel dompdf 中的每一页添加页码?

我从这里得到:https://github.com/barryvdh/laravel-dompdf我的Controller是这样的:publicfunctionlistdata(){$pdf=PDF::loadView('print_tests.test_pdf');$pdf->setPaper('L','landscape');return$pdf->stream('test_pdf.pdf');}我的观点是这样的:header1header2header3content-row-1content-row-1content-row-1content-row-2content-row-

php - 如何在运行时使用Laravel注册新的语言 key ?

我用laravel5.3编写了一个脚本,检查运行时给定语言中是否存在lang键。如果密钥不存在,它会将其添加到文件中。但是,如果第一次周围的密钥不存在,我添加它,然后我做另一个检查“在同一请求期间”看是否存在该密钥,它会说它不存在。所以加载的语言将不会意识到我在文件中添加了新的密钥,因为laravel在内存中加载了密钥,而我只是在硬盘上写入文件。这就是我检查当前是否存在密钥的方法Lang::has($key,$language,false);当我评估Illuminate\Translation\Translator类时,我看到load方法检查一个组是否被加载,它不会再次加载它。这是拉维

php - 如何展平 laravel 递归关系集合(树集合)?

如何将具有层次结构自引用模型的集合、树集合展平为单一维度集合。我有一个包含parent和child的自引用模型。我希望结果返回一个Eloquent集合,而不是一个简单的集合或数组。array已被用作result结果,方便演示关系是这样声明的。publicfunctionparent(){return$this->belongsTo(self::class,'parent_id');}publicfunctionparentRecursive(){return$this->parent()->with('parentRecursive');}publicfunctionchildren(