www/app/Http/Controllers/PlayerController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        if(!Auth::user()->hasRole('superadmin'))
            return redirect()->route('player.index');
        $validatedData = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
        ]);
        $player = User::create([
            'name' => $validatedData['name'],
            'email' => $validatedData['email'],
            'password' => bcrypt('password')
        ]);
        $player->roles()
            ->attach(Role::where('name', 'player')->first());
        return redirect()->route('player.index')->with('status', 'Player added');
    }
public function store ( Request $ request ) { if ( ! Auth :: user ( ) -> hasRole ( 'superadmin' ) ) return redirect ( ) -> route ( 'player.index' ) ; $ validatedData = $ request -> validate ( [ 'name' => 'required|string|max:255' , 'email' => 'required|string|email|max:255|unique:users' , ] ) ; $ player = User :: create ( [ 'name' => $ validatedData [ 'name' ] , 'email' => $ validatedData [ 'email' ] , 'password' => bcrypt ( 'password' ) ] ) ; $ player -> roles ( ) -> attach ( Role :: where ( 'name' , 'player' ) -> first ( ) ) ; return redirect ( ) -> route ( 'player.index' ) -> with ( 'status' , 'Player added' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .