the_unforgiven_II
the_unforgiven_II

Reputation: 361

Laravel - Decision not to use Eloquent

If i choose not to use Eloquent can i just use standard PHP queries, reason I ask is I'm using the User model and built-in Auth but need an extra Auth package for another set of users, so just wondered if this could be done or what other way to achieve what I need

Anyone have any suggestions ?

Upvotes: 0

Views: 114

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Yes you can, but if you still need to use Laravel's Auth, your new User model will have to implement Illuminate\Auth\UserInterface, here's a glance of what you`ll have to have:

use Illuminate\Auth\UserInterface;

class User extends Eloquent implements UserInterface {

    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier() 
    {
        /// reuturn authIdentifier
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        /// reuturn authPassword
    }

}

If you are using whole a different package for authentication, you don't have to worry about the User model or even Eloquent, the package you're using will have to treat that by itself.

And at any time you might be able to use raw queries (which are not Eloquent, but Query Builder, but you can start them from Eloquent, yes).

Upvotes: 2

Related Questions