douliao8760 2014-01-27 21:40
浏览 48
已采纳

Laravel - 决定不使用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 ?

  • 写回答

1条回答 默认 最新

  • dtotuki47568 2014-01-27 21:46
    关注

    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).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?