I have 3 models,
User, Host and URL
Basically, URL has a host_id field, so that I could relate the 2 models together.
Here are my models:
User Model (user_urls is just a pivot table containing user_id and url_id)
class User extends Authenticatable
{
... irrelevant codes here...
public function urls(){
return $this->belongsToMany('\App\Models\SEO\Url', 'user_urls', 'user_id', 'url_id')->withTimestamps();
}
}
Host model:
class Host extends Model
{
protected $fillable = [
'friendly_name',
'hosting_cost',
'login_url',
'username', //encrypted field
'password' //encrypted field
];
...some irrelevant codes here...
-- MUTATORS/ACCESSORS---
public function setPasswordAttribute($value){
$this->attributes['password'] = \Crypt::encrypt($value);
}
public function getPasswordAttribute($value){
return $this->attributes['password'] = \Crypt::decrypt($value);
}
...
}
URL model:
class Url extends Model
{
protected $table = 'urls';
protected $with = ['host'];
public function host(){
return $this->belongsTo('\App\Models\SEO\Host', 'host_id');
}
}
Now, when I try to do this on a controller,
return $this->user->urls();
It returns an exception
in BaseEncrypter.php line 44
at BaseEncrypter->getJsonPayload('password') in Encrypter.php line 96
at Encrypter->decrypt('password') in Facade.php line 218
at Facade::__callStatic('decrypt', array('password')) in Host.php line 69
at Crypt::decrypt('password') in Host.php line 69
at Host->getPasswordAttribute('password') in Model.php line 2782
at Model->mutateAttribute('password', 'password') in Model.php line 2794
at Model->mutateAttributeForArray('password', 'password') in Model.php line 2529
at Model->attributesToArray() in Model.php line 2490
at Model->toArray() in Model.php line 2600
at Model->relationsToArray() in Model.php line 2492
at Model->toArray() in Model.php line 2480
at Model->jsonSerialize() in Collection.php line 1005
at Collection->Illuminate\Support\{closure}(object(Url))
at array_map(object(Closure), array(object(Url), object(Url), object(Url))) in Collection.php line 1013
at Collection->jsonSerialize() in Collection.php line 1024
at Collection->toJson() in Response.php line 68
at Response->morphToJson(object(Collection)) in Response.php line 46
at Response->setContent(object(Collection)) in Response.php line 197
at Response->__construct(object(Collection)) in Router.php line 1030
at Router->prepareResponse(object(Request), object(Collection)) in ControllerDispatcher.php line 95
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 28
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(UsersUrlController), object(Route), object(Request), 'api_filter') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), '\App\Http\Controllers\Users\UsersUrlController', 'api_filter') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 59
I can clearly see that it is trying to decrypt a string "password", of course it will throw an error simply because it is not encrypted, but on my database it is encrypted. Why is it already encrypted before even being decrypted? Is this a possible bug?
Thanks!
Maybe you can try:
public function urls(){
return $this->belongsToMany('\App\Models\SEO\Url', 'user_urls', 'user_id', 'url_id');
}
And call the property like this:
$user=User->with('urls')->where('id',$id)->first();
$user->urls->create_at;
Related
I came across this error when I tried to run php artisan serve. I downloaded this project and tried to run it encountered this error instead.
Is there any solution that you guys can help me. Thanks in advance. I am using xampp as a host server for my project.
ErrorException in Builder.php line 1185: count(): Parameter must be an array or an object that implements Countable
in Builder.php line 1185
at HandleExceptions->handleError('2', 'count(): Parameter must be an array or an object that implements Countable', 'C:\xampp\htdocs\bootup-master\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php', '1185', array('scope' => object(Closure), 'parameters' => array(object(Builder)), 'query' => object(Builder)))
at count(null) in Builder.php line 1185
at Builder->callScope(object(Closure)) in Builder.php line 1216
at Builder->applyScopes() in Builder.php line 314
at Builder->get() in HomeController.php line 30
at HomeController->index()
at call_user_func_array(array(object(HomeController), 'index'), array()) in Controller.php line 80
at Controller->callAction('index', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(HomeController), object(Route), 'index') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(HomeController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\HomeController', 'index') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TagstripMiddleware.php line 19
at TagstripMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(TagstripMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
at require_once('C:\xampp\htdocs\bootup-master\public\index.php') in server.php line 21
This error is caused by the PHP version. Most probably PHP 7.2 version. See below:
Document changes of PHP 7.2
To solve this issue:
Donwgrade your PHP version
OR
Modify line 1185 of the
vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php file
$originalWhereCount = count ($ query-> wheres);
to
$originalWhereCount = 0;
if (is_array ($ query-> wheres) || is_object ($ query-> wheres)) {
$originalWhereCount = count ($ query-> wheres);
}
I'm creating a laravel app that use Cassandra as database.I'm using this driver :https://github.com/cubettech/lacassa but I'm getting issues for setting up the Laravel Auth fonctionality even if I did what they said on the driver github page.
here is my stack trace after submiting the register form:
Whoops, looks like something went wrong.
1/1 InvalidQueryException in Builder.php line 227: Undefined column name id
in Builder.php line 227
at FutureRows->get() in Builder.php line 227
at Builder->executeCql('select * from users where id = 'mdiongue00#gmail.com' limit 1') in Builder.php line 197
at Builder->get(array('*')) in Builder.php line 1580
at Builder->first(array('*')) in Builder.php line 1556
at Builder->find('mdiongue00#gmail.com') in DatabaseUserProvider.php line 57
at DatabaseUserProvider->retrieveById('mdiongue00#gmail.com') in SessionGuard.php line 132
at SessionGuard->user() in GuardHelpers.php line 49
at SessionGuard->check() in RedirectIfAuthenticated.php line 20
at RedirectIfAuthenticated->handle(object(Request), object(Closure))
at call_user_func_array(array(object(RedirectIfAuthenticated), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(AuthController), object(Route), object(Request), 'showRegistrationForm') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Auth\AuthController', 'showRegistrationForm') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/usr/local/apache2/htdocs/urlshortener/public/index.php') in server.php line 21
When I use auth()->user()->roles() with tinker it works without any problem but when I use it on the web page itself I get:
BadMethodCallException in Builder.php line 2405:
Call to undefined method Illuminate\Database\Query\Builder::addEagerConstraints()
What does this mean, what could be the reason for this? Here is the related model:
class User extends Authenticatable
{
public function roles(){
return Role::where('id', 6);
}
}
I am using laravel 5.2 and the complete error is like below.
PS: I guess the problem has something to do with the way I am using it in other parts of the site. Thats why it works on tinker. the other parts look like they require the result of the form of Relation obj which I can't provide after the where query.
BadMethodCallException in Macroable.php line 74:
Method addEagerConstraints does not exist.
in Macroable.php line 74
at Collection->__call('addEagerConstraints', array(array(object(User), object(User)))) in Builder.php line 667
at Collection->addEagerConstraints(array(object(User), object(User))) in Builder.php line 667
at Builder->loadRelation(array(object(User), object(User)), 'roles', object(Closure)) in Builder.php line 645
at Builder->eagerLoadRelations(array(object(User), object(User))) in Builder.php line 322
at Builder->get()
at call_user_func_array(array(object(Builder), 'get'), array()) in Relation.php line 343
at Relation->__call('get', array()) in Relation.php line 113
at BelongsTo->get() in Relation.php line 113
at Relation->getEager() in Builder.php line 676
at Builder->loadRelation(array(object(Comment), object(Comment), object(Comment)), 'user', object(Closure)) in Builder.php line 645
at Builder->eagerLoadRelations(array(object(Comment), object(Comment), object(Comment))) in Builder.php line 322
at Builder->get() in ModuleController.php line 27
at ModuleController->main(array())
at call_user_func_array(array(object(ModuleController), 'main'), array(array())) in Container.php line 507
at Container->call(array(object(ModuleController), 'main'), array(array())) in Container.php line 602
at Container->callClass('\App\Modules\Preview_coupons_comments\Controllers\ModuleController#main', array(array()), null) in Container.php line 502
at Container->call('\App\Modules\Preview_coupons_comments\Controllers\ModuleController#main', array(array())) in Facade.php line 219
at Facade::__callStatic('call', array('\App\Modules\Preview_coupons_comments\Controllers\ModuleController#main', array(array()))) in PageController.php line 220
at App::call('\App\Modules\Preview_coupons_comments\Controllers\ModuleController#main', array(array())) in PageController.php line 220
at PageController->getPageByName()
at call_user_func_array(array(object(PageController), 'getPageByName'), array()) in Controller.php line 80
at Controller->callAction('getPageByName', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(PageController), object(Route), 'getPageByName') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(PageController), object(Route), object(Request), 'getPageByName') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PageController', 'getPageByName') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckActive.php line 23
at CheckActive->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckActive), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php line 51
at Debugbar->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Debugbar), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/Users/skeletor/Sites/project/public/index.php') in server.php line 21
this is the dd of the normal relation $this->belongsToMany(Role::class);
BelongsToMany {#971 ▼
#table: "role_user"
#foreignKey: "user_id"
#otherKey: "role_id"
#relationName: "roles"
#pivotColumns: []
#pivotWheres: []
#pivotWhereIns: []
#pivotCreatedAt: null
#pivotUpdatedAt: null
#query: Builder {#996 ▶}
#parent: User {#319 ▶}
#related: Role {#812 ▶}
}
and this is the modified return Role::where('id', 6); one
Builder {#812 ▼
#query: Builder {#317 ▶}
#model: Role {#997 ▶}
#eagerLoad: []
#macros: []
#onDelete: null
#passthru: array:11 [▶]
#scopes: []
#removedScopes: []
}
they look quite different and this may the reason.
As #SimonSvensson asked here is my Comment model
class Comment extends Model
{
/**
* Fields that can be mass assigned.
*
* #var array
*/
protected $fillable = ['active', 'user_id', 'text', 'url'];
/**
* Comment morphs to models in commentable_type.
* Get all of the owning commentable models.
*
* #return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function commentable()
{
// morphTo($name = commentable, $type = commentable_type, $id = commentable_id)
// requires commentable_type and commentable_id fields on $this->table
return $this->morphTo();
}
/**
* Query scope ofWebsite.
*
* #param \Illuminate\Database\Eloquent\Builder
* #return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOfWebsite($query)
{
return $query->where(function($q){
$q->whereNull('commentable_id')->whereNull('commentable_type');
});
}
/**
* Comment belongs to User.
*
* #return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
// belongsTo(RelatedModel, foreignKey = user_id, keyOnRelatedModel = id)
return $this->belongsTo(User::class);
}
}
It looks like you're trying to eager-load the User.roles relation, but it isn't a proper relation, it's just a method that invokes a call to Role::where(...). Relation methods are usually returning something like $this->hasMany(Role::class).
The title says it all:
Laravel 5.2 - TokenMismatchException in VerifyCsrfToken.php after renaming the project
If I rename the project file and access it from that folder specific URL, i get the token mismatch exception.
TokenMismatchException in VerifyCsrfToken.php line 67:
in VerifyCsrfToken.php line 67
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
The tokens are perfectly set int he meta tags and as well as the script tags after jquery.
In the post headers, the token goes accurately and successfully. But laravel throws the above message.
I'm working on a laravel 5 project but now I receive the error:
ReflectionException in Container.php line 736:
Class App\Http\Controllers\routes does not exist
But that's strange because when I do a new installation of laravel that App\Http\Controllers\routes doesn't even excist? The routes file is normally in App\Http. What could be wrong, here is the full error:
> ReflectionException in Container.php line 736:
Class App\Http\Controllers\routes does not exist
in Container.php line 736
at ReflectionClass->__construct('App\Http\Controllers\routes') in Container.php line 736
at Container->build('App\Http\Controllers\routes', array()) in Container.php line 626
at Container->make('App\Http\Controllers\routes', array()) in Application.php line 674
at Application->make('App\Http\Controllers\routes') in ControllerDispatcher.php line 85
at ControllerDispatcher->makeController('App\Http\Controllers\routes') in ControllerDispatcher.php line 57
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\routes', 'index') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54