app/Http/Controllers/MahasiswaController.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)
    {
            $request->validate([
                'Nim' => 'required',
                'Nama' => 'required',
                'Kelas' => 'required',
                'Jurusan' => 'required',
                'No_Handphone' => 'required',
                'E_Mail' => 'required',
                'TglLahir' => 'required',
            ]);
            Mahasiswa::create($request->all());
            return redirect()->route('mahasiswas.index')
                ->with('success', 'Mahasiswa Berhasil Ditambahkan');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'Nim' => 'required' , 'Nama' => 'required' , 'Kelas' => 'required' , 'Jurusan' => 'required' , 'No_Handphone' => 'required' , 'E_Mail' => 'required' , 'TglLahir' => 'required' , ] ) ; Mahasiswa :: create ( $ request -> all ( ) ) ; return redirect ( ) -> route ( 'mahasiswas.index' ) -> with ( 'success' , 'Mahasiswa Berhasil Ditambahkan' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//melakukan validasi data //fungsi eloquent untuk menambah data //jika data berhasil ditambahkan, akan kembali ke halaman utama