app/Http/Controllers/PpcController.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)
    {
        $dataUser = request()->validate([
            'username' => 'required|string|max:100',
            'email' => 'required|email|unique:users',  
            'password' => 'required|min:6',
            'confirm-password' => 'required|same:password|min:6'
        ]);
        $dataPPC = request()->validate([
            'nama' => 'required|string|max:120',
            'gender' => 'required|string|in:L,P',
            'tanggal_lahir' => 'required|date',
            'alamat' => 'required|string|max:190',
            'no_hp' => 'required|string|max:20'
        ]);
        $dataUser['password'] = \bcrypt($dataUser['password']);
        $dataUser['role'] = 'ppc';
        $user = User::create($dataUser);
        $user->ppc()->create($dataPPC);    
        return redirect()->route('ppc.index')->with('success', 'Data Staff PPC berhasil dimasukan');
    }
public function store ( Request $ request ) { $ dataUser = request ( ) -> validate ( [ 'username' => 'required|string|max:100' , 'email' => 'required|email|unique:users' , 'password' => 'required|min:6' , 'confirm-password' => 'required|same:password|min:6' ] ) ; $ dataPPC = request ( ) -> validate ( [ 'nama' => 'required|string|max:120' , 'gender' => 'required|string|in:L,P' , 'tanggal_lahir' => 'required|date' , 'alamat' => 'required|string|max:190' , 'no_hp' => 'required|string|max:20' ] ) ; $ dataUser [ 'password' ] = \ bcrypt ( $ dataUser [ 'password' ] ) ; $ dataUser [ 'role' ] = 'ppc' ; $ user = User :: create ( $ dataUser ) ; $ user -> ppc ( ) -> create ( $ dataPPC ) ; return redirect ( ) -> route ( 'ppc.index' ) -> with ( 'success' , 'Data Staff PPC berhasil dimasukan' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .