app/Http/Controllers/AnggotaController.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)
    {
        $count = Anggota::where('nisn',$request->input('nisn'))->count();
        if($count>0){
            Session::flash('message', 'Already exist!');
            Session::flash('message_type', 'danger');
            return redirect()->to('anggota');
        }
        $this->validate($request, [
            'nama' => 'required|string|max:255',
            'nisn' => 'required|string|max:20|unique:anggota',
            'tempat_lahir' => 'required|string|max:255',
        ]);
        Anggota::create($request->all());
        alert()->success('Berhasil.','Data telah ditambahkan!');
        return redirect()->route('anggota.index');
    }
public function store ( Request $ request ) { $ count = Anggota :: where ( 'nisn' , $ request -> input ( 'nisn' ) ) -> count ( ) ; if ( $ count > 0 ) { Session :: flash ( 'message' , 'Already exist!' ) ; Session :: flash ( 'message_type' , 'danger' ) ; return redirect ( ) -> to ( 'anggota' ) ; } $ this -> validate ( $ request , [ 'nama' => 'required|string|max:255' , 'nisn' => 'required|string|max:20|unique:anggota' , 'tempat_lahir' => 'required|string|max:255' , ] ) ; Anggota :: create ( $ request -> all ( ) ) ; alert ( ) -> success ( 'Berhasil.' , 'Data telah ditambahkan!' ) ; return redirect ( ) -> route ( 'anggota.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .