Posts

Showing posts with the label Laravel 5

Can Anyone Explain Laravel 5.2 Multi Auth With Example

Answer : After lots of digging and lots of questions & answers I have finally managed to work Laravel 5.2 Multi Auth with two table, So I'm writing Answer of my own Question. How to implement Multi Auth in Larvel 5.2 As Mentioned above. Two table admin and users Laravel 5.2 has a new artisan command. php artisan make:auth it will generate basic login/register route , view and controller for user table. Make a admin table as users table for simplicity. Controller For Admin app/Http/Controllers/AdminAuth/AuthController app/Http/Controllers/AdminAuth/PasswordController (note: I just copied these files from app/Http/Controllers/Auth/AuthController here) config/auth.php //Authenticating guards 'guards' => [ 'user' =>[ 'driver' => 'session', 'provider' => 'user', ], 'admin' => [ 'driver' => 'session', 'pro...

Available Actions For OnUpdate / OnDelete In Laravel 5.x

Answer : You can do all the options mentioned in phpmyadmin this way: $table->...->onDelete('CASCADE'); $table->...->onDelete('SET NULL'); $table->...->onDelete('RESTRICT'); // do not call the onDelete() method if you want the RESTRICT option. You have to make sure you set the foreign key field as nullable: $table->...->unsigned()->nullable(); Referring to the source code: `vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php` in the function compileForeign() It just appends whatever you pass in to the table query. if (! is_null($command->onDelete)) { $sql .= " on delete {$command->onDelete}"; } if (! is_null($command->onUpdate)) { $sql .= " on update {$command->onUpdate}"; } So, make sure you pass one of the following: "cascade", "no action", "restrict", or "set null" NOTE: Do NOT use...