Laravel cannot load the specific User model - php

I have just uploaded a Laravel 4.1 application to Bluehost, and since I cannot login into my app, it keeps telling me that my User class doesn't exist.
I'm using psr-4 to load my specific dir/namespace and inside that I have created my own User class under the model dir.
I have also changed the auth.config file pointing the User model in the specific dir.
I checked the composer autoload_classmap which keeps loading the original app/model/User class. I don't know if this is incorrect since it is the same in my local dev ambient.
Here's the funny thing. Only the User model doesn't work, the others, declared in the same namespace are working as expected.
Looks like Laravel doesn't consider the auth.config file.
Someone can give a hand with this?

Related

Laravel CRUD API Fatal Error: Trait 'Illuminate\Database\Eloquent\Factories\HasFactory' not found

I was following this tutorial, but with my own dataset: https://www.positronx.io/php-laravel-crud-operations-mysql-tutorial
And I got stuck on the phase of Creating and storing data.
After filling all the fields:
Im getting this error:
When I comment use HasFactory it's showing this
Please help!
The HasFactory trait wasn't introduced until Laravel 8x. That's also when they moved all the models into the app/Models directory.
I'm guessing that you're on Laravel 7x (or earlier), which does not have the HasFactory trait, and where all the models are stored in the app directory by default.
If you want to follow that tutorial, you'll want to start with a Laravel 8x application. If you want to stay on 7x, you'll need to adjust some things to work in 7x. For example, delete the use statement for the HasFactory trait. Additionally, your models are probably in the App namespace, not the App\Models namespace.

I get an error that i have already fixed, when trying to open register form in laravel

in the RegistersUsers trait, i used to pass permisions to register view through function showRegistrationForm, but i have restructured my project and i decided that i dont need to pass permissions through that function anymore, so i deleted permissions codes from that trait and i also deleted the model and everything about permission. but the funny thing is when i start my project, i get an error that "Class 'App\Permission' not found"; but in my project there is nothing like permission anymore. let me attach picture to explain more.
here is the RegistersUsers trait in my project.
And here is the error i get in my browser
And in my browser, the RegistersUsers looks like this, which is not the same as my file looks. it looks exactly like how it did before i made changes.
help please, i need this now.
Are you using Laravel test server or a configured apache? Generally you should never direcly edit framework files.
Anyway seems you're editing different projects, in visual studio code your path is "datastroco-laravel" in your browser "datastroco-mr-umeme"

RegistersUsers trait in Laravel 7.2

I want to override core registration functionality in Laravel 7.23.2. According to this source I need to override the register() function, which belongs to the trait 'RegistersUsers' and is located in vendor/laravel/framework/src/Illuminate/Foundation/Auth/
However, in this folder all I see is User.php and "Access" folder which does not have the aforementioned trait as well. I've searched the entire vendor folder and there is no file RegistersUsers.php. In GitHub of Laravel Framework 7.x, there is no such file as well.
But I can see one in Laravel 5.5. So I assume registration method resides somewhere else.
So basically my two questions:
In registration controller there is a line use RegistersUsers;
If there is no RegistersUsers.php, then what is being used here?
This will probably be answered by the first one, but where I can find the core implementation of register() method?
This was moved out of the core and is part of the laravel/ui package. So the file would be in vendor/laravel/ui/auth-backend/.
You can open that and see the register method, but you may not have to override it. That method calls other methods that you can override as well. Some of these methods are only there basically so you can override them so you don't have to override the entire Registration system.

Laravel 5.2.45 Where is the Auth Controller and model?

Where are the "out-of-the-box" Authentication Controllers and Models for Laravel 5.2.45? I've searched thoroughly and I keep seeing it's in app/http/auth but only HomeController and a minimal Controller.php is there.
Also, It's a fresh install with only minimal edits such as new files to views and assets such as css and js. I used "php artisan make:auth" and the output only stated the new view files.
I'm learning Laravel to replace Codeigniter and this is a stump I've stumbled upon.
The model files are stored directly inside the app directory.
The controller files are stored inside app/Http/Controllers directory. Auth Controller is inside app/Http/Controllers/Auth.
By the way in the mentioned version of laravel no HomeController file is generated by laravel.

Where to put things in Laravel 5.1

I'm a bit confused about where something like this belongs to Laravel.
I want to write a web service client wrapper in laravel, and I want to access it like this:
\MyWSClient::getSomeInfoAbout($someId);
then the code will connect to the web service to http://www.someapi.com/api/getSomeInfoAbout?id=$someid&type=json with OAuth2 or some token requests, then fetch the data, keep token information until it expires, refresh token if needed etc.
But where will I put the code? In the vendor directory as a new package? I'm moving this code from a computer to another computer except vendor,storage and node_modules folders, because they are huge and when I do this, I will have to move only one folder in the vendor directory. And I'll need to publish a package under development to composer if I want portability etc.
Is there any other way to do something like this?
I think I've found the answer.
First I needed to use jeroen-g/laravel-packager package to create a new package using artisan console. I could've done that by hand, but I didn't know the required files.
Second, I've created a new package in the packages folder with my desired class name.
Third, I've added the provider and the alias for the class in app.php.
After that, I've created a test method in my controller and wrote a route for that. I called the static method I've written in the SkeletonClass the packager created for me.
And it worked with some tweaking after creation.
I've used php artisan packager:new tpaksu mypackage --i command for an interactive package creation which is cool.
Note: I've just learned the existence of this package, I'm not advertising it :)

Categories