app/Http/Controllers/UsahaController.php
/**
	 * Remove the specified resource from storage.
	 *
	 * @param  \App\Usaha  $usaha
	 * @return \Illuminate\Http\Response
	 */
Remove the specified resource from storage.
Remove the specified resource from storage .
public function destroy($uuid) {
		try {
			$usaha = Usaha::find($uuid);
			$usaha_id = $usaha->id;
			$galeri = UsahaFoto::find($usaha_id);
			if ($usaha->hasFoto->count() > 0) {
				File::delete(public_path() . $usaha->hasFoto->foto);
			}
			$usaha->delete();
		} catch (FileNotFoundException $e) {
		}
		return redirect()->route('usaha.index')->with('success', 'Usaha deleted successfully');
	}
public function destroy ( $ uuid ) { try { $ usaha = Usaha :: find ( $ uuid ) ; $ usaha_id = $ usaha -> id ; $ galeri = UsahaFoto :: find ( $ usaha_id ) ; if ( $ usaha -> hasFoto -> count ( ) > 0 ) { File :: delete ( public_path ( ) . $ usaha -> hasFoto -> foto ) ; } $ usaha -> delete ( ) ; } catch ( FileNotFoundException $ e ) { } return redirect ( ) -> route ( 'usaha.index' ) -> with ( 'success' , 'Usaha deleted successfully' ) ; }
Remove the specified resource from storage.
Remove the specified resource from storage .
// dd($usaha->hasFoto->count()); // File::delete($galeri->foto);