ollieread / multiauth

Laravel multi auth
441 stars 109 forks source link

Separate E-Mail Templaes #34

Closed shimberger closed 10 years ago

shimberger commented 10 years ago

It would be nice to have completely different email templates. Would it be possible to add a key to the different providers e.g.:

'multi' => array(
    'backend' => array(
        'driver' => 'eloquent',
        'model' => 'BackendUser'
       'reminder' => array('email' => 'backend.email.reminder'))
    ),
    'user' => array(
        'email' => 'frontend.emails.auth.reminder',
        'driver' => 'eloquent',
        'model' => 'User'
        'reminder' => array('email' => 'frontend.email.reminder'))
   )
)

I would be willing to work on this but my experience with Laravel is limited so I don't know how easy this would be. A starting hint would be nice.

ollieread commented 10 years ago

Thinking about this, it's something I've actually overlooked. I'll be looking into making this change in the near future. The proposed config structure would be something like you suggested except not an array:

'multi'     => array(

        'user'  => array(
            'driver'    => 'eloquent',
            'model'     => 'Models\User',
            'reminder' => 'email.user-reminder'
        ),

        'admin' => array(
            'driver'    => 'eloquent',
            'model'     => 'Models\Admin',
            'reminder' => 'email.admin-reminder'
        )

),
shimberger commented 10 years ago

Thank you so much. That makes sense. To be honest I didn't spent too much time proposing my structure (roughly the time it took to copy & paste ;)). If there is any way I can help please let me know.

ollieread commented 10 years ago

It's a relatively quick fix so I should be able to do it in no time. Depends if I get a break from work, but I'll try and implement it asap.

No worries about the structure, all I needed was the suggestion :)

ghislainf commented 10 years ago

In the meantime of this feature, you can use this little trick :

@if($user instanceof Admin)
    @include('your.custom.admin.reminder', compact('token', 'user'))
@elseif($user instanceof User)
    @include('your.custom.user.reminder', compact('token', 'user'))
@endif
ollieread commented 10 years ago

Yeah, I haven't had chance to look further at this, sorry. If somebody would like to make a PR I can take a look?