app/Http/Controllers/User/TabunganController.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 (!Hash::check(request('password'), auth()->user()->password)) {
            session()->flash('warning', 'Password anda salah');
            return back();
        }
        $santri = Santri::whereCode(request('code'))->first();
        if ($santri->user_id != userId()) {
            return Redirect::route('dashboard');
        }
        request()->validate([
            'desc'          => 'required',
            'status'        => 'required',
            'nominal'       => 'required',
        ]);
        $invoice = request('status') . '-' .  date('mdy') . 'I' . $santri->id . 'T' . userId() . 'P' . Str::random(5);
        Tabungan::create([
            'invoice'       => $invoice,
            'santri_id'     => $santri->id,
            'desc'          => request('desc'),
            'status'        => request('status'),
            'nominal'       => request('nominal'),
            'toko_id'       => null,
            'user_id'       => userId()
        ]);
        session()->flash('success', 'Tabungan dari ' . $santri->nama . ' berhasil ' . status(request('status')) . ' sebesar ' . number_format(request('nominal')) . ' pada ' . date('d F Y , h:i'));
        TimeLine('Tabungan dari ' . $santri->nama . ' berhasil ' . status(request('status')) . ' sebesar ' . number_format(request('nominal')) . ' pada ' . date('d F Y , h:i'));
        return Redirect::route('tabungan.invoice', $invoice);
    }
public function store ( Request $ request ) { if ( ! Hash :: check ( request ( 'password' ) , auth ( ) -> user ( ) -> password ) ) { session ( ) -> flash ( 'warning' , 'Password anda salah' ) ; return back ( ) ; } $ santri = Santri :: whereCode ( request ( 'code' ) ) -> first ( ) ; if ( $ santri -> user_id != userId ( ) ) { return Redirect :: route ( 'dashboard' ) ; } request ( ) -> validate ( [ 'desc' => 'required' , 'status' => 'required' , 'nominal' => 'required' , ] ) ; $ invoice = request ( 'status' ) . '-' . date ( 'mdy' ) . 'I' . $ santri -> id . 'T' . userId ( ) . 'P' . Str :: random ( 5 ) ; Tabungan :: create ( [ 'invoice' => $ invoice , 'santri_id' => $ santri -> id , 'desc' => request ( 'desc' ) , 'status' => request ( 'status' ) , 'nominal' => request ( 'nominal' ) , 'toko_id' => null , 'user_id' => userId ( ) ] ) ; session ( ) -> flash ( 'success' , 'Tabungan dari ' . $ santri -> nama . ' berhasil ' . status ( request ( 'status' ) ) . ' sebesar ' . number_format ( request ( 'nominal' ) ) . ' pada ' . date ( 'd F Y , h:i' ) ) ; TimeLine ( 'Tabungan dari ' . $ santri -> nama . ' berhasil ' . status ( request ( 'status' ) ) . ' sebesar ' . number_format ( request ( 'nominal' ) ) . ' pada ' . date ( 'd F Y , h:i' ) ) ; return Redirect :: route ( 'tabungan.invoice' , $ invoice ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
# Chek apakah santri dari admin