public function delAuthor($id) { $author_katalog = AuthorKatalog::where('author', '=', $id)->get(); foreach ($author_katalog as $value) { //remove from author katalog table $ak = AuthorKatalog::find($value->id); $ak->delete(); } $author = Author::find($id); if (file_exists($author->foto)) { unlink('image/' . $author->foto); } $author->delete(); //remove from author table return Redirect::to('admin/author'); }