I have the following code:
$coretable = new coretable;
$coretableKeyArray = [];
$coretableKeyArray["Internal_key"] = $coretableInput["Internal_key"];
if(is_array($coretableKeyArray)){
log::info("recognized as array");
}
$lastInsert = $coretable->firstOrCreate($coretableKeyArray, $coretableInput);
The array for argument 1 of firstOrCreate() looks like this:
[2020-02-27 07:30:50] local.INFO: array (
'Internal_key' => 'TESTKEY_4',
)
the is_array() also returns true on $coretableKeyArray
However, when doing the call to firstOrCreate() here:
$lastInsert = $coretable->firstOrCreate($coretableKeyArray, $coretableInput);
I get this error:
(1/1) TypeError
Argument 1 passed to Illuminate\Database\Eloquent\Builder::firstOrCreate() must be of the type array, int given, called in E:\aether-backend\vendor\illuminate\support\Traits\ForwardsCalls.php on line 23
in Builder.php line 415
at Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))in ForwardsCalls.php line 23
at Model->forwardCallTo(object(Builder), 'firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in Model.php line 1618
at Model->__call('firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in modelInteractions.php line 128
Why is that? Also, why does the log of the error show me:
Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))
Why is the first argument "4" here? What does it represent? Because it cant represent the value of the first argument of the call to firstOrCreate() because that was an entirely different one...
EDIT:
Here is the full errorstack, as requested per comment:
(1/1) TypeError
Argument 1 passed to Illuminate\Database\Eloquent\Builder::firstOrCreate() must be of the type array, int given, called in E:\aether-backend\vendor\illuminate\support\Traits\ForwardsCalls.php on line 23
in Builder.php line 415
at Builder->firstOrCreate(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4'))in ForwardsCalls.php line 23
at Model->forwardCallTo(object(Builder), 'firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in Model.php line 1618
at Model->__call('firstOrCreate', array(4, array('coretable_id' => 4, 'description_itc' => 'EXTENSION_ITC_4')))in modelInteractions.php line 127
at modelInteractions->insertModel(array('Internal_key' => 'TESTKEY_4'), array('Internal_key' => 'TESTKEY_4', 'extensiontable_itc' => array('description_itc' => 'EXTENSION_ITC_4'), 'extensiontable_sysops' => array('description_sysops' => 'EXTENSION_SYSOPS_4')), array('extensiontable_itc', 'extensiontable_sysops'))in UserController.php line 100
at UserController->insertDataCreateNewItem(object(Request))
at call_user_func_array(array(object(UserController), 'insertDataCreateNewItem'), array(object(Request)))in BoundMethod.php line 32
at BoundMethod::Illuminate\Container\{closure}()in Util.php line 36
at Util::unwrapIfClosure(object(Closure))in BoundMethod.php line 90
at BoundMethod::callBoundMethod(object(Application), array(object(UserController), 'insertDataCreateNewItem'), object(Closure))in BoundMethod.php line 34
at BoundMethod::call(object(Application), array(object(UserController), 'insertDataCreateNewItem'), array(), null)in Container.php line 590
at Container->call(array(object(UserController), 'insertDataCreateNewItem'), array())in RoutesRequests.php line 376
at Application->callControllerCallable(array(object(UserController), 'insertDataCreateNewItem'), array())in RoutesRequests.php line 342
at Application->callLumenController(object(UserController), 'insertDataCreateNewItem', array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 316
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 278
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 258
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 52
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Authenticate.php line 36
at Authenticate->handle(object(Request), object(Closure))in Pipeline.php line 171
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Pipeline.php line 105
at Pipeline->then(object(Closure))in RoutesRequests.php line 413
at Application->sendThroughPipeline(array('App\\Http\\Middleware\\Authenticate'), object(Closure))in RoutesRequests.php line 259
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\UserController#insertDataCreateNewItem', 'middleware' => array('auth')), array()))in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 52
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in CORS.php line 34
at CORS->handle(object(Request), object(Closure))in Pipeline.php line 171
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request))in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request))in Pipeline.php line 105
at Pipeline->then(object(Closure))in RoutesRequests.php line 413
at Application->sendThroughPipeline(array('App\\Http\\Middleware\\CORS'), object(Closure))in RoutesRequests.php line 171
at Application->dispatch(null)in RoutesRequests.php line 108
at Application->run()in index.php line 28
EDIT:
Question can be closed or deleted, the solution to the problem was somewhere else.
Try this:
$lastInsert = $coretable->firstOrCreate((array)$coretableKeyArray, $coretableInput);
If that doesn't work, in case you've overloaded firstOrCreate make sure it doesn't do custom casts within it.
Instead of storing in a variable you can directly put it in the method.
Much cleaner and also readable.
$coretable->firstOrCreate([
'Internal_key' => $coretableInput["Internal_key"]
], $coretableInput);
Related
Laravel: v5.7.28
Voyager: v1.2.0
PHP: 7.2
Database: MySQL 8.0
I setup Voyager Admin Panel on my Laravel E-commerce.
When I try to login, I see an error:
(1/1) BadMethodCallException Method Illuminate\Http\Request::validate
does not exist.
Stack:
--
in Macroable.php line 100
at Request->__call('validate', array(array('email' => 'required\|string', 'password' => 'required\|string')))in AuthenticatesUsers.php line 68
at VoyagerAuthController->validateLogin(object(Request))in VoyagerAuthController.php line 24
at VoyagerAuthController->postLogin(object(Request))
at call_user_func_array(array(object(VoyagerAuthController), 'postLogin'), array(object(Request)))in Controller.php line 54
at Controller->callAction('postLogin', array(object(Request)))in ControllerDispatcher.php line 45
at ControllerDispatcher->dispatch(object(Route), object(VoyagerAuthController), 'postLogin')in Route.php line 219
at Route->runController()in Route.php line 176
at Route->run()in Router.php line 682
at Router->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in VerifyCsrfToken.php line 75
at VerifyCsrfToken->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in StartSession.php line 63
at StartSession->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in EncryptCookies.php line 66
at EncryptCookies->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 104
at Pipeline->then(object(Closure))in Router.php line 684
at Router->runRouteWithinStack(object(Route), object(Request))in Router.php line 659
at Router->runRoute(object(Request), object(Route))in Router.php line 625
at Router->dispatchToRoute(object(Request))in Router.php line 614
at Router->dispatch(object(Request))in Kernel.php line 176
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request))in InjectDebugbar.php line 65
at InjectDebugbar->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in CheckForMaintenanceMode.php line 62
at CheckForMaintenanceMode->handle(object(Request), object(Closure))in Pipeline.php line 163
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request))in Pipeline.php line 104
at Pipeline->then(object(Closure))in Kernel.php line 151
at Kernel->sendRequestThroughRouter(object(Request))in Kernel.php line 116
at Kernel->handle(object(Request))in index.php line 55
Error in Laravel https://github.com/laravel/framework/blob/6.x/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L67
protected function validateLogin(Request $request)
{
$request->validate([
$this->username() => 'required|string',
'password' => 'required|string',
]);
}
I check the documentation https://laravel.com/docs/5.7/validation and it's correct code.
Please help, why doesn't it work?
i don't proper reason for this but i faced same issue after update to 5.6.
Use
use Request;
instead of
use Illuminate\Http\Request;
this works for me
You should use
$this->validate(); method and pass in $request as the first parameter
or, you can use the
Validator::make(); method and pass in $request as the first parameter
i have problem in storing data of users ,when user sign up i store half of info in table user and other half in another table ,when hit register butttom i get that error i found that in table user info is stored correctley but in other table nothing is saved.
error
in HasAttributes.php line 818
at HandleExceptions->handleError(2, 'Illegal offset type', 'C:\\wamp\\www\\Menoon1\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Concerns\\HasAttributes.php', 818, array()) in HasAttributes.php line 818
at Model->getCasts() in HasAttributes.php line 803
at Model->hasCast('email', array('date', 'datetime')) in HasAttributes.php line 832
at Model->isDateCastable('email') in HasAttributes.php line 565
at Model->isDateAttribute('email') in HasAttributes.php line 525
at Model->setAttribute('email', 'dde#hg.com') in Model.php line 223
at Model->fill(array('email' => 'dde#hg.com')) in Model.php line 145
at Model->__construct(array('email' => 'dde#hg.com')) in Model.php line 268
at Model->newInstance(array('email' => 'dde#hg.com')) in Builder.php line 1030
at Builder->newModelInstance(array('email' => 'dde#hg.com')) in Builder.php line 723
at Builder->create(array('email' => 'dde#hg.com')) in Model.php line 1332
at Model->__call('create', array(array('email' => 'dde#hg.com'))) in Model.php line 1344
at user_emails->create(array('email' => 'dde#hg.com')) in Model.php line 1344
at Model::__callStatic('create', array(array('email' => 'dde#hg.com'))) in RegisterController.php line 94
at user_emails::create(array('email' => 'dde#hg.com')) in RegisterController.php line 94
at RegisterController->create(array('_token' => 'FZqd7Sc3fQRzmaQ0ImXYebzltzkygJsbKpNcZhv4', 'username' => 'vbnm v bnmm', 'email' => 'dde#hg.com', 'password' => '1111111', 'password_confirmation' => '1111111', 'fname' => 'vbn', 'lname' => 'bnm', 'address' => 'bnm', 'membership' => 'Normal', 'pic' => object(UploadedFile))) in RegistersUsers.php line 33
at RegisterController->register(object(Request))
at call_user_func_array(array(object(RegisterController), 'register'), array(object(Request))) in Controller.php line 55
at Controller->callAction('register', array(object(Request))) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(RegisterController), 'register') in Route.php line 204
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 54
at require_once('C:\\wamp\\www\\Menoon1\\public\\index.php') in server.php line 21
user mode
public function useremail()
{
return $this->hasOne('App\user_emails');
}
other table code
public function user()
{
return $this->belongsTo('App\User');
}
code in registercontroller
protected function create(array $data)
{
$fileName = 'null';
Input::file('pic')->store('avatars');
if (Input::file('pic')->isValid()) {
$destinationPath = public_path('uploads/files');
$extension = Input::file('pic')->getClientOriginalExtension();
$fileName = uniqid().'.'.$extension;
Input::file('pic')->move($destinationPath, $fileName);
}
$user= User::create([
'fname' => $data['fname'],
'lname' => $data['lname'],
'address' => $data['address'],
'username' => $data['username'],
'membership' => $data['membership'],
'pic'=>$fileName,
'password' => bcrypt($data['password']),
]);
$useremail=user_emails::create(['email'=>$data['email']]);
// dd($useremail);
$user->useremail()->save($useremail);
return $user;
}
I dont know your model, but if has composite keys, collection cannot get attributes
Try
$user->useremail()->save(new UserEmail(['email'=>$data['email']]));
Given that the model of the useremail is UserEmail.
And your models are mixed up: it should be for App\UserEmail:
public function user()
{
return $this->belongsTo('App\User');
}
and for App\User
public function userEmail()
{
return $this->hasOne('App\user_emails');
}
Notice the convention, for your own good. 'useremail' becomes userEmail'. The model files become User.php and UserEmail.php. Your tables 'users' and 'user_emails' respectively. As thus, the relationship in 'user_emails' should be 'user_id'. And done.
I faced the same issue, it happened because in the Model I defined also a primary key, but it was already set in the database with a clause when the table was created.
when i try to register and send an email to the user i got this error. It was working till yesterday. From today it gives me this and i cant figure out why.
By the way on local testing this work's. I'm stuck. Help please
ErrorException in compiled.php line 7512:
file_put_contents(/var/www/html/storage/framework/views/53de219dee4f11a2db4f64a2c574ad02db5613f4.php): failed to open stream: Permission denied
in compiled.php line 7512
at HandleExceptions->handleError('2', 'file_put_contents(/var/www/html/storage/framework/views/53de219dee4f11a2db4f64a2c574ad02db5613f4.php): failed to open stream: Permission denied', '/var/www/html/bootstrap/cache/compiled.php', '7512', array('path' => '/var/www/html/storage/framework/views/53de219dee4f11a2db4f64a2c574ad02db5613f4.php', 'contents' => 'Please activate your account by clicking on the following link. <?php echo e(route('auth.activate', $token)); ?> ', 'lock' => false))
at file_put_contents('/var/www/html/storage/framework/views/53de219dee4f11a2db4f64a2c574ad02db5613f4.php', 'Please activate your account by clicking on the following link. <?php echo e(route('auth.activate', $token)); ?> ', '0') in compiled.php line 7512
at Filesystem->put('/var/www/html/storage/framework/views/53de219dee4f11a2db4f64a2c574ad02db5613f4.php', 'Please activate your account by clicking on the following link. <?php echo e(route('auth.activate', $token)); ?> ') in compiled.php line 15769
at BladeCompiler->compile('/var/www/html/resources/views/email/auth/activation.blade.php') in compiled.php line 15682
at CompilerEngine->get('/var/www/html/resources/views/email/auth/activation.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'token' => object(ActivationToken), 'activeToken' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message))) in compiled.php line 15517
at View->getContents() in compiled.php line 15505
at View->renderContents() in compiled.php line 15489
at View->render() in Mailer.php line 458
at Mailer->getView('email.auth.activation', array('token' => object(ActivationToken), 'activeToken' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message))) in Mailer.php line 331
at Mailer->addContent(object(Message), 'email.auth.activation', null, null, array('token' => object(ActivationToken), 'activeToken' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message))) in Mailer.php line 205
at Mailer->send('email.auth.activation', array('token' => object(ActivationToken), 'activeToken' => null, 'connection' => null, 'queue' => null, 'delay' => null, 'message' => object(Message)), object(Closure)) in Mailable.php line 117
at Mailable->send(object(Mailer)) in Mailer.php line 192
at Mailer->send(object(SendActivationToken)) in MailableMailer.php line 99
at MailableMailer->send(object(SendActivationToken)) in SendActivationEmail.php line 30
at SendActivationEmail->handle(object(UserRegistered))
at call_user_func_array(array(object(SendActivationEmail), 'handle'), array(object(UserRegistered))) in compiled.php line 10332
at Dispatcher->Illuminate\Events\{closure}(object(UserRegistered))
at call_user_func_array(object(Closure), array(object(UserRegistered))) in compiled.php line 10266
at Dispatcher->fire('App\Events\UserRegistered') in helpers.php line 480
at event(object(UserRegistered)) in AppServiceProvider.php line 25
at AppServiceProvider->App\Providers\{closure}(object(User))
at call_user_func_array(object(Closure), array(object(User))) in compiled.php line 10266
at Dispatcher->fire('eloquent.created: App\User', array(object(User))) in compiled.php line 11029
at Model->fireModelEvent('eloquent.created: App\User', false) in compiled.php line 10996
at Model->performInsert(object(Builder)) in compiled.php line 10941
at Model->save() in compiled.php line 10599
at Model::create(array('name' => 'Alessandro Mazari', 'surname' => 'Mazari', 'email' => 'alessandro.mazzari.v.l#gmail.com', 'password' => '$2y$10$R/lwIQ5.dgNgArYE3AuyGeDSyUWoILtnT2LvrDGNjV9aDevj9/Xnq', 'hidden_profile' => 'off', 'faction' => 'soon', 'mac_address_handlebar' => '', 'active' => false)) in RegisterController.php line 76
at RegisterController->create(array('_token' => 'Jeh3Amk6XGHDiFz5fqYyBIGYGblbNlZxwzM9r4lJ', 'name' => 'Alessandro Mazari', 'surname' => 'Mazari', 'email' => 'alessandro.mazzari.v.l#gmail.com', 'password' => 'alessa', 'password_confirmation' => 'alessa', 'faction' => 'soon', 'mac_address_handlebar' => '', 'hidden_profile' => 'off')) in compiled.php line 2695
at RegisterController->register(object(Request))
at call_user_func_array(array(object(RegisterController), 'register'), array(object(Request))) in compiled.php line 9584
at Controller->callAction('register', array(object(Request))) in compiled.php line 9611
at ControllerDispatcher->dispatch(object(Route), object(RegisterController), 'register') in compiled.php line 8665
at Route->runController() in compiled.php line 8646
at Route->run(object(Request)) in compiled.php line 8355
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24
at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 10177
at SubstituteBindings->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3312
at VerifyCsrfToken->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13749
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 12155
at StartSession->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13495
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 13432
at EncryptCookies->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 10054
at Pipeline->then(object(Closure)) in compiled.php line 8356
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8347
at Router->dispatchToRoute(object(Request)) in compiled.php line 8338
at Router->dispatch(object(Request)) in compiled.php line 2575
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3374
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 10069
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 10054
at Pipeline->then(object(Closure)) in compiled.php line 2519
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2503
at Kernel->handle(object(Request)) in index.php line 53
I cannot comment because I have joined stackoverflow recently and I do not have enough credits so I post an answer.
Laravel needs write permission to storage folder ( and Just this folder). so please run:
sudo chmod -R 7777 storage
I hope I have helped,
regards,
Whenever you see something like failed to open stream: Permission denied', '/var/www/html/bootstrap/cache you should remind yourself that Laravel needs to have write permissions to specific directories.
sudo chmod 777 dir_name is your friend here :)
Quoting the docs:
Directory Permissions
After installing Laravel, you may need to configure some permissions.
Directories within the storage and the bootstrap/cache directories
should be writable by your web server or Laravel will not run.
This question already has answers here:
Laravel view not found exception
(19 answers)
Closed 2 years ago.
I already deployed my Laravel app into my VPS. It works fine on localhost. I think the error is in my routes or maybe the controller because the path is still going into my local machine directory (see error message line 2) but I really can't see the problem in the code.
I have tried using php artisan config:cache, php artisan cache:clear, php artisan route:cache but it still doesn't work. It still refers to my local machine directory.
This is the directory of index.blade.php
Root
|-- portofolio
|-- app
|-- bootstrap
|-- config
|-- database
|-- resources
|-- assets
|-- lang
|-- views
|-- index.blade.php
|-- routes
|-- storage
|-- tests
|-- vendor
|-- public_html
|-- css
|-- img
|-- js
|-- vendor
This is the Route
Route::get('/', ['as' => 'home', 'uses' => 'Portofolio#link']);
This is the Controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Portofolio extends Controller
{
public function link() {
$categories = [
'1' => 'Print Design',
'2' => 'Logo Design',
'3' => 'Web Design',
'4' => 'Product Design',
'5' => 'Character Design',
'6' => 'Packaging Design'
];
$projects = [
'1' => 'IMSAA Training Certificate',
'2' => 'Rusticity Logo',
'3' => 'Handy Production Website',
'4' => 'Nihon no Matsuri Bag Project',
'5' => 'The Chin - Captain Jack Sparrow',
'6' => 'Rusticity Packaging'
];
$images = [
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6'
];
$skills = [
'1' => 'Photoshop',
'2' => 'Ms. Office',
'3' => 'Laravel',
'4' => 'PHP',
'5' => 'HTML',
'6' => 'MySQL'
];
$points = [
'1' => '80%',
'2' => '90%',
'3' => '60%',
'4' => '60%',
'5' => '60%',
'6' => '60%'
];
return view('index')->withCategories($categories)->withProjects($projects)->withImages($images)->withSkills($skills)->withPoints($points);
}
}
This is the error message (see line 2)
InvalidArgumentException in FileViewFinder.php line 137:
View [index] not found.
1. in FileViewFinder.php line 137
2. at FileViewFinder->findInPaths('index', array('E:\Laravel\portofolio\resources\views')) in FileViewFinder.php line 79
3. at FileViewFinder->find('index') in Factory.php line 174
4. at Factory->make('index', array(), array()) in helpers.php line 856
5. at view('index') in Portofolio.php line 56
6. at Portofolio->link()
7. at call_user_func_array(array(object(Portofolio), 'link'), array()) in Controller.php line 55
8. at Controller->callAction('link', array()) in ControllerDispatcher.php line 44
9. at ControllerDispatcher->dispatch(object(Route), object(Portofolio), 'link') in Route.php line 190
10. at Route->runController() in Route.php line 144
11. at Route->run(object(Request)) in Router.php line 653
12. at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
13. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
14. at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
15. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
16. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
17. at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
18. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
19. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
20. at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
21. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
22. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
23. at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
24. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
25. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
26. at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
27. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
28. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
29. at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
30. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
31. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
32. at Pipeline->then(object(Closure)) in Router.php line 655
33. at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
34. at Router->dispatchToRoute(object(Request)) in Router.php line 607
35. at Router->dispatch(object(Request)) in Kernel.php line 268
36. at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
37. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
38. at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
39. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
40. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
41. at Pipeline->then(object(Closure)) in Kernel.php line 150
42. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
43. at Kernel->handle(object(Request)) in index.php line 54
I have solved the problem.
The problem is that my server is not being set up properly because the domain doesn't connect properly to my VPS. Contacted the hosting provider and the problem was solved.
If anyone have this problem just check
Have you already done php artisan config:cache or php artisan config:clear?
Did you name your view correctly as yourview.blade.php?
Did you place the view correctly in resources\views?
Make sure you have the index.blade.php in the views dir, here the index.blade.php is not the index.php in the / dir.
I'm new to Lumen and i am trying to setup authentification using OAuth2 with this tutorial
when i try to access any route i got this error:
ReflectionException in Container.php line 738:
Class Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse does not exist
in Container.php line 738
at ReflectionClass->__construct('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse') in Container.php line 738
at Container->build('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', array()) in Container.php line 633
at Container->make('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', array()) in Application.php line 205
at Application->make('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request)) in OAuthExceptionHandlerMiddleware.php line 36
at OAuthExceptionHandlerMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(OAuthExceptionHandlerMiddleware), '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->Laravel\Lumen\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in RoutesRequests.php line 626
at Application->sendThroughPipeline(array('LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse'), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(object(Request)) in RoutesRequests.php line 327
at Application->run(object(Request)) in index.php line 28
bootstrap\app.php
$app->middleware([
'LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse' // <--- added
]);
$app->routeMiddleware([
'check-authorization-params' => 'Optimus\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware',
'csrf' => 'Laravel\Lumen\Http\Middleware\VerifyCsrfToken',
'oauth' => 'Optimus\OAuth2Server\Middleware\OAuthMiddleware',
'oauth-owner' => 'Optimus\OAuth2Server\Middleware\OAuthOwnerMiddleware'
]);
$app->register(App\Providers\EventServiceProvider::class);
$app->register('LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider');
$app->register('Optimus\OAuth2Server\OAuth2ServerServiceProvider');
routes.php
$app->group(['prefix' => 'v1','namespace' => 'App\Http\Controllers'], function($app)
{
$app->get('post','PostController#index');
}
Just run
composer require illuminate/cookie
Then add this code at bootstrap/app.php
$app->singleton('cookie', function () use ($app) {
return $app->loadComponent('session', 'Illuminate\Cookie\CookieServiceProvider', 'cookie');
});
$app->bind('Illuminate\Contracts\Cookie\QueueingFactory', 'cookie');
ref https://github.com/esbenp/lumen-api-oauth/issues/23