app/Http/Controllers/PetugasController.php
/**
     * Remove the specified resource from storage.
     *
     * @param  \App\Petugas  $petuga
     * @return \Illuminate\Http\Response
     */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy(Petugas $petuga)
    {
        if(\Auth::user()->id == $petuga->user->id){
            return redirect()->route('petugas.index')->with('error','Tidak dapat menghapus akun ini');
        }
        if(File::exists('images/'.$petuga->photo)){
            unlink('images/'.$petuga->photo);
        }
        if($petuga->delete()){
            return redirect()->route('petugas.index')->with(
                "success","Data berhasil disimpan");
        }else{
            return redirect()->route('petugas.index')->with(
                "error","Data gagal disimpan");
        }
    }
public function destroy ( Petugas $ petuga ) { if ( \ Auth :: user ( ) -> id == $ petuga -> user -> id ) { return redirect ( ) -> route ( 'petugas.index' ) -> with ( 'error' , 'Tidak dapat menghapus akun ini' ) ; } if ( File :: exists ( 'images/' . $ petuga -> photo ) ) { unlink ( 'images/' . $ petuga -> photo ) ; } if ( $ petuga -> delete ( ) ) { return redirect ( ) -> route ( 'petugas.index' ) -> with ( " success " , " Data berhasil disimpan " ) ; } else { return redirect ( ) -> route ( 'petugas.index' ) -> with ( " error " , " Data gagal disimpan " ) ; } }
Remove the specified resource from storage.
Remove the specified resource from storage .