Clean up / refactor this store() method
Okay, let me get this right (I have no experience working with an LDAP): The Auth class you're first using for $attempt is actually the LDAP library you're implementing?

I don't think I understand the logic in your code. You attempt to log in to the user, and if they successfully login, you check to see if the user exists? I must be misunderstanding something.

Well, assuming you know how exactly this works, I'll just point out a couple refactor points I can see:


In terms of breaking this apart into responsibilities: your method handles both authentication and registration. I can imagine registration being handled in another method.
I doubt you need to flash forward this entire parameter: 'welcome, ' . $un. Have your Blade file check for the flash and display "welcome, ". Since you're only sending one, just pass through $un. Either that or make it an array and pass two values: type of flash, and message.
Speaking of $un. There are better variable names, give yours some meaning and quality to them.
You can manage to un-nest your code a little:



if ($attempt) {
    ...
} else {
    return Redirect...
}



This piece could really just be:

if (!$attempt) {
    return Redirect...
}

// *What used to be inside the if*