Skip to content

08 Admin seeder

Ivan Radunovic edited this page May 9, 2017 · 1 revision

Kreiramo novi seeder:

php artisan make:seeder AdminSeeder
<?php

use Illuminate\Database\Seeder;

class AdminSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $adminRole = \App\Models\Role::where('name', 'Administrator')->first();

        \App\Models\User::create([
            'name' => 'Admin',
            'email' => '[email protected]',
            'password' => \Illuminate\Support\Facades\Hash::make('secret'),
            'role_id' => $adminRole->id
        ]);
    }
}

Dodali smo admina u bazu podataka, međutim on je trenutno redirektovan na stranu za obične korisnike nakon logina, potrebno je da to ispravimo.

Clone this wiki locally