I have the following Laravel 4.2 controller code in a store method:
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
I've tested this code with var_dump and the $validator is definitely returning the correct error messages.
The errors however are not being passed to the view. When attempting var_dump($errors) on the view I get the following exception
Undefined variable: errors.
I've also tried (by accident) var_dump($error)and it is of type object(Illuminate\Support\ViewErrorBag) however it does not contain any errors.
Does anyone know what the problem might be? Thanks in advance.
After looking into this issue for two whole days - I've finally fixed it! In the end I removed the vendor folder and ran composer update. I can only assume that something within Laravel was corrupt in the initial download.
Related
I am working on Laravel 8 , I have tried to use findOrFail method in order to set redirection to 404 error not found instead of displaying error but it is showing this error method findOrFail not found,
this is the line of code in ProfilesController that is causing the error
$user = User::findOrFail($user);
this is the output of the error
enter image description here
Thanks in advance,
Look like your code works fine. The issue Php Strom not able to identify methods.
I always use query() method to get autocomplete model methods
$user=User::query()->findOrFail($user);
or you might need to install any extension which can able to identify laravel methods
I'm using Crinsane/LaravelShoppingcart package.
In my controller
Cart::add($request->id, $request->name, 1, $request->price)->associate('App\Product');
I've been associated Product model
and in view, I loop through it,
now if I die and dump it {{ dd($item->model->id) }} it works but without dd $item->model->id doesn't work instead gives error
Trying to get property 'id' of non-object
It sounds like the line you suspect of beeing the root for you error may not be the error that is shown. If you dd the code after this line is no longer executed therefore a potential access" to an id of non-object is also not executed. Take a look further down your code to see if the problem might be in a place that is executed after your dd location!
Additionally you could look into the laravel optional helper to catch the error and return a default value: https://laravel.com/docs/5.6/helpers#method-optional
I am working on a codeigniter project. My website is going good but sometime an error occur that CI controller not found in core/codeigniter.php line number 234. I'm not able to find exact problem. Please provide me a valid solution. Thanks in advance for your efforts.
Here is how line number 234 looks like
function &get_instance()
{
return CI_Controller::get_instance();
}
One thing that is amazing me that this error occcur sometime not quite oftenly.
Check your controller name. Controller name should always start with a capital letter. As shown below.
Controller_name.php
The problem is that I'm reciving Class 'session' not found error.
But the funny fact is that I'm not using session class. Anyway I'm using session namespace use Session;. I've found out that the problem occurs when I'm returning view.
If I return simple string or number it works, but when I use
return view('catering.prices')->with(['name' => 'Victoria']);
or
return view('greetings', ['name' => 'Victoria']);
I'm reciving the error.
Log:
[2016-10-06 11:38:54] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'session' not found' in D:\app\storage\framework\views\397c6d5694d7a10e04cabd271a3359cfd11a387e.php:16
Update
I'm seeing that it's not returning new views - I have now about 40 views. The old one are working well but when I create new views I'm reciving the error.
Answer
The problem was wrongly set permissions for specific user in my database. Thank you for your effort.
Anybody has some idea?
Try like this,
return view('catering.prices',['name'=> 'Victoria']);
OR
return view('catering.prices')->with('name', 'Victoria');
check here : https://laravel.com/docs/5.2/views
PHP Fatal error: Call to undefined function thebuggenie\core\helpers\make_url() in ../core/helpers/TextParser.php on line 706
This is the error that I keep getting when trying to set up the VCS-integration successfully in The Bug Genie. It is an issue tracker that has VCS (git) integration. The commits can be linked to a project, and with the correct commit-message to the right issue using a git-hook. Then you can view the commit in the issue tracker. Apparently the commit is getting linked to the project, but it doesn't get linked to the issue because of the error. Can anybody help me?
The source code on GitHub.
Thanks in advance!
I've found the solution. There appears to be an error in the vcs-integration. Apparently the ui.inc.php-library is not loaded when using the git-hook.
So the temporary solution (until they solve it) is:
At modules/vcs_integration/Vcs_integration.php:226, add:
framework\Context::loadLibrary('ui');
As far as i see, make_url function is defined in a global namespace, but is called from namespace thebuggenie\core\helpers. So i suppose that's your problem