app/Http/Controllers/MemberController.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([
            'nama' => 'required|string|max:255',
            'no_hp' => 'required|numeric|unique:members',
        ]);
        $member = new Member();
        $member->nama = $request->nama;
        $member->no_hp = $request->no_hp;
        $member->kode_member = Str::random(6);
        $member->hari = Carbon::now(new \DateTimeZone('Asia/Jakarta'))->format('Y-m-d');
        $member->saldo = 0;
        $member->created_at = Carbon::now(new \DateTimeZone('Asia/Jakarta'));
        $member->save();
        return redirect()->route('member.index')->with('success', 'Data member berhasil ditambahkan');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'nama' => 'required|string|max:255' , 'no_hp' => 'required|numeric|unique:members' , ] ) ; $ member = new Member ( ) ; $ member -> nama = $ request -> nama ; $ member -> no_hp = $ request -> no_hp ; $ member -> kode_member = Str :: random ( 6 ) ; $ member -> hari = Carbon :: now ( new \ DateTimeZone ( 'Asia/Jakarta' ) ) -> format ( 'Y-m-d' ) ; $ member -> saldo = 0 ; $ member -> created_at = Carbon :: now ( new \ DateTimeZone ( 'Asia/Jakarta' ) ) ; $ member -> save ( ) ; return redirect ( ) -> route ( 'member.index' ) -> with ( 'success' , 'Data member berhasil ditambahkan' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .