Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Delete tags
James Colee232f2e2238c
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex ba15b3ea83..46cf6fea45 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -39,6 +39,37 @@ class TagController extends ControllerView::share('tagOptions', $tagOptions);}+ /**+ * @param Tag $tag+ *+ * @return \Illuminate\View\View+ */+ public function delete(Tag $tag)+ {+ $subTitle = 'Delete "' . e($tag->tag) . '"';++ // put previous url in session+ Session::put('tags.delete.url', URL::previous());++ return view('tags.delete', compact('tag', 'subTitle'));+ }++ /**+ * @param Tag $tag+ *+ * @return \Illuminate\Http\RedirectResponse+ */+ public function destroy(Tag $tag, TagRepositoryInterface $repository)+ {++ $tagName = $tag->tag;+ $repository->destroy($tag);++ Session::flash('success', 'Tag "' . e($tagName) . '" was deleted.');++ return Redirect::to(route('tags.index'));+ }+/*** @return \Illuminate\View\View*/diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 030813b8a6..9ca40a968b 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -15,6 +15,18 @@ use Illuminate\Support\Collection;class TagRepository implements TagRepositoryInterface{+ /**+ * @param Tag $tag+ *+ * @return boolean+ */+ public function destroy(Tag $tag)+ {+ $tag->delete();++ return true;+ }+/*** @return Collection*/@@ -60,15 +72,17 @@ class TagRepository implements TagRepositoryInterface** @return Tag*/- public function update(Tag $tag, array $data) {- $tag->tag = $data['tag'];- $tag->date = $data['date'];+ public function update(Tag $tag, array $data)+ {+ $tag->tag = $data['tag'];+ $tag->date = $data['date'];$tag->description = $data['description'];- $tag->latitude = $data['latitude'];- $tag->longitude = $data['longitude'];- $tag->zoomLevel = $data['zoomLevel'];- $tag->tagMode = $data['tagMode'];+ $tag->latitude = $data['latitude'];+ $tag->longitude = $data['longitude'];+ $tag->zoomLevel = $data['zoomLevel'];+ $tag->tagMode = $data['tagMode'];$tag->save();+return $tag;}}\ No newline at end of filediff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.phpindex 124aa88707..937bc51b4a 100644--- a/app/Repositories/Tag/TagRepositoryInterface.php+++ b/app/Repositories/Tag/TagRepositoryInterface.php@@ -31,4 +31,11 @@ interface TagRepositoryInterface {* @return Tag*/public function update(Tag $tag, array $data);++ /**+ * @param Tag $tag+ *+ * @return boolean+ */+ public function destroy(Tag $tag);}\ No newline at end of filediff --git a/resources/views/tags/delete.blade.php b/resources/views/tags/delete.blade.phpnew file mode 100644index 0000000000..0320cf1a1a--- /dev/null+++ b/resources/views/tags/delete.blade.php@@ -0,0 +1,44 @@+@extends('layouts.default')+@section('content')+{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $tag) !!}+{!! Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('tags.destroy',$tag->id)]) !!}+<div class="row">+ <div class="col-lg-6 col-md-12 col-sm-12">+ <div class="panel panel-red">+ <div class="panel-heading">+ Delete tag "{{{$tag->tag}}}"+ </div>+ <div class="panel-body">+ <p>+ Are you sure that you want to delete tag "{{{$tag->tag}}}"?+ </p>++ @if($tag->transactionjournals()->count() > 0)+ <p class="text-info">+ Tag "{{{$tag->name}}}" still has {{$tag->transactionjournals()->count()}} transaction(s) connected+ to it. These will <strong>not</strong> be removed but will lose their connection to this tag.+ </p>+ @endif++ <p>+ <button type="submit" class="btn btn-default btn-danger">Delete permanently</button>+ <a href="{{URL::previous()}}" class="btn-default btn">Cancel</a >+ </p>+ </div>+ </div>+ </div>+</div>++<div class="row">+ <div class="col-lg-6">+ <div class="form-group">+ <div class="col-sm-8">++ </div>+ </div>+ </div>+</div>+++{!! Form::close() !!}+@stop