【问题标题】:Get attribute from config.php of Sentry 2 for Laravel 4从 Laravel 4 的 Sentry 2 的 config.php 获取属性
【发布时间】:2015-09-23 12:37:17
【问题描述】:

我正在尝试修改 cartalyt/sentry 供应商文件夹中的原始 User.php 文件,因为我想使用同一电子邮件注册两个帐户,但 Sentry 的原始代码不允许此功能,所以我添加了一个属性到 config.php 文件

/app/config/packages/cartalyst/sentry/config.php

但我不知道如何让这个属性在这个文件中使用:

/vendor/cartalyst/sentry/src/Cartalyst/Sentry/Users/Eloquent/User.php

因为在该文件中我可以简单地添加一个 if 来检查我是想在每封电子邮件中注册一个用户还是使用同一电子邮件注册更多用户。

或者如果你有更好的想法会很高兴知道它。

希望你能帮帮我!

【问题讨论】:

    标签: php laravel-4 cartalyst-sentry


    【解决方案1】:
    You dont need to touch that file what you should do is 
    
    **remove this**     
    $table->unique('email');
    **from this file**  
    **your-app/vendor/cartalyst/sentry/src/migrations/2012_12_06_225921_migration_cartalyst_sentry_install_users.php**
    
    That would remove the unique constraint on creating a user with one single email
    
    Then you might need to drop the db or look for a way to re-run the migrations.
    

    【讨论】:

    • 没错,这是一个更好的主意。谢谢!
    • 实际上我仍然有同样的问题,所以我认为现在我没有其他选择,只能直接更改为该 User.php 文件并从 .gitignore 中删除该供应商文件夹。
    • 您重新运行迁移了吗??
    • 是的,但是保存用户的功能默认有一个方法来比较当前电子邮件是否已经在数据库中
    • 我非常同意你的观点,你可能必须在此处的用户模型中删除这个定义 -> your-app/vendor/cartalyst/sentry/src/Cartalyst/Sentry/Users/Eloquent/User/ 检查如果用户已经存在 $query = $this->newQuery(); $persistedUser = $query->where($this->getLoginName(), '=', $login)->first(); if ($persistedUser and $persistedUser->getId() != $this->getId()) { throw new UserExistsException("用户已经存在登录 [$login],用户的登录必须是唯一的。"); }
    猜你喜欢
    • 2014-03-31
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 1970-01-01
    • 2014-02-24
    • 2014-01-26
    • 2014-02-19
    • 2014-09-05
    相关资源
    最近更新 更多