app/Http/Controllers/User/SantriController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $code)
    {
        $santri = Santri::whereCode($code)->first();
        if ($santri->user_id != userId()) {
            return Redirect::route('dashboard');
        }
        $attr = request()->validate([
            'nama'      => 'required',
            'alamat'    => 'required'
        ]);
        $santri->update($attr);
        TimeLine('Data santri berhasil diedit a.n ' . request('nama'));
        session()->flash('success', 'Data santri berhasil diedit a.n ' . request('nama'));
        return Redirect::back();
    }
public function update ( Request $ request , $ code ) { $ santri = Santri :: whereCode ( $ code ) -> first ( ) ; if ( $ santri -> user_id != userId ( ) ) { return Redirect :: route ( 'dashboard' ) ; } $ attr = request ( ) -> validate ( [ 'nama' => 'required' , 'alamat' => 'required' ] ) ; $ santri -> update ( $ attr ) ; TimeLine ( 'Data santri berhasil diedit a.n ' . request ( 'nama' ) ) ; session ( ) -> flash ( 'success' , 'Data santri berhasil diedit a.n ' . request ( 'nama' ) ) ; return Redirect :: back ( ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
# Chek apakah santri dari admin