Laravel / Kakao Class 'App\Http\Controllers\Cache' not found - laravel

I try to set up kakao login to my Shopify store, but when I run the test I encountered this message error, what should I do? Thank you

The Cache facade doesn't live in the App\Http\Controllers namespace. If you do not include a use statement at the top of your PHP files for your classes, it is assumed the class does live in the same namespace.
The Laravel Cache facade lives in the Illuminate\Support\Facades namespace so at the top of your KakaoController with your other use statements, add the following:
use Illuminate\Support\Facades\Cache;

You must need to add "use Illuminate\Support\Facades\Cache;" on top of controller, middleware, command, event or blade files.
for example
<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\Cache;
class KaKaoController extends Controller {
...
or "use \Cache;"

Related

Error message comes when trying to view template using controller

I am new to laravel and use the laravel 9.37v version. I have the following error message.
I created a blade template. I could view that blade template using view but after I tried to view that template using the controller I got this error message.
Target class [PagerConntroller] does not exist
Please check the spelling, if it is correct try to import the controller class in the Route. Im assuming the controller name is PagerConntroller and the function that you need to call is index so your web.php or api.php should be like :
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PagerConntroller;
Route::get('view',[PagerConntroller::class, 'index']);
Or else you can use the controllers without importing by simply uncommenting the namespace variable inside app/Providers/RouteServiceProvider.php line:29 the variable will look like protected $namespace = 'App\\Http\\Controllers'; then your route file should be like
<?php
use Illuminate\Support\Facades\Route;
Route::get('view','PagerConntroller#index');
If you tried both the ways and still the error persists kindly check your class name and the namespace as well

Laravel: "$ php artisan route:list" does not show route list in App\Http\Controllers\API

I created a UserController inside
app/Http/Controllers/API/UserController.php
Inside the UserController.php I have this
namespace App\Http\Controllers\API;
Inside the api.php I have this
Route::apiResources(['user' => 'API\UserController']);
I get this error below when I try to display the route list.
Error: Target class [App\Http\Controllers\UserController] does not
exist.
How do we tell Laravel that the UserController is inside app/Http/Controllers/API?
You need to defined the namespace, so laravel can find the controller:
<?php
namespace App\Http\Controllers\API;
...
class UserController extends Controller {
You have already defined the api.php with namespace API:
Route::apiResources(['user' => 'API\UserController']);
Try to clear the routes cache:
php artisan route:clear
php artisan optimize
Have you checked that the path you specify is correct ?
and you could also check the namespace in the UserController, correspond to:
namespace App\Http\Controllers\API ?
Or also you can simply add the controllers in the wep / api routes :
Route::get('prefix', 'DirOfYourController\YourController#SomeFunction);
Or as stated on the documentation you could take a look here:
https://laravel.com/docs/master/routing#route-group-namespaces
Well it's definitely because one of your web.php or api.php file
make sure that namespace of the file is correct in there for instance
Route::get('foo', 'API\UserController');
You need to follow only 2 steps to achieve the same:
Step1:
Define the correct name space in your UserController as below
namespace App\Http\Controllers\API;
Step2: Define route with directory name in your web.php for eg.
Route::get('dashboard', 'API\UserController#dashboard');

Laravel 5 Can't Use User Class

I'm new to Laravel. I just installed Laravel 5 and have been going through some video tutorials in order to learn how it works.
I want to use the User class as it seems like it is very useful. In my web.php (routes) file, I have:
use app\Models\User;
Route::get('/users', function (){
$users = User::all(); //select * from users
return $users;
});
I get the following error upon loading that route in my browser:
I have a User.php file placed in my app/Models/ directory, and also changed in my auth.php file for it to reference this.
There are countless questions like this online and I try the fixes but I can't seem to get it to work. Any ideas?
Thanks!
Remove Models from use statement. It's not directory... Model is in namespace App so use:
use App\User;
Namespace and Directory is completely different things...
Or if you want to use in directory app/Models go to User.php model file and change namespace from App to App\Models

cant create laravel usercontroller

usually when I want to create controller I use php artisan
php artisan make:controller UserController
but in this case I have error in my terminal
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'User' not found
and I wanna use it for users page - update and display users, as well as route
Route::resource('/user', 'UserController');
should I use it like that or something else? and why do I get error?
You get this error because you've used User class somewhere in the code (some controller probably). Find out where did you used it and add this clause to the top of that class:
use App\User;
Or just use full namespace, for example:
\App\User::get();

Upload images in laravel 5

I'm facing a problem in uploading images to server in laravel 5, the problem is some images uploaded normally, and other images breaks the server, and I got this message
The specified URL cannot be found.
I'm using this route in routes.php
Route::any('/{lang}/REGISTER','createAccountController#index');
My class is :
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Application;
use App\Http\Requests;
use Request;
use Route;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Lang;
use App\ImageCircleCrop;
class createAccountController extends Controller
{
public function index($lang,Request $request){
// process form data here
}
}
I don't get any error messages in server logs, in fact, the application does not reach the controller code at all. Any help?
New Update: I noticed that the problem occurs just for png images, submitting form with file of type png make a crash on the application. The route does not work after that, and I got the message: "The specified URL cannot be found". Is it something related to the server configuration, or with laravel configration?

Resources