From c4bd6a8a1a3fea1183f840cd78cd53ecd886f9da Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Sat, 15 Sep 2018 00:22:57 -0300 Subject: [PATCH] Joining Take and Return controllers on just Take (store and delete) --- app/Http/Controllers/ReturnController.php | 18 ------------------ app/Http/Controllers/TakeController.php | 9 +++++++++ resources/views/home.blade.php | 5 ++--- resources/views/home/usedItem.blade.php | 5 ++++- 4 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 app/Http/Controllers/ReturnController.php diff --git a/app/Http/Controllers/ReturnController.php b/app/Http/Controllers/ReturnController.php deleted file mode 100644 index d0acd62..0000000 --- a/app/Http/Controllers/ReturnController.php +++ /dev/null @@ -1,18 +0,0 @@ -items()->find(request('item')); - $item->used_by = null; - $item->save(); - - return redirect('home'); - } -} diff --git a/app/Http/Controllers/TakeController.php b/app/Http/Controllers/TakeController.php index ab30be1..85d0b54 100644 --- a/app/Http/Controllers/TakeController.php +++ b/app/Http/Controllers/TakeController.php @@ -15,4 +15,13 @@ class TakeController extends Controller $item->save(); return redirect('home'); } + + public function delete(Request $request) + { + $item = User::find(\Auth::id())->items()->find(request('item')); + $item->used_by = null; + $item->save(); + + return redirect('home'); + } } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 0347eda..3a26222 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -5,8 +5,7 @@
-

Your items

- +
Your items
@if (session('status'))
-@endsection +@endsection \ No newline at end of file diff --git a/resources/views/home/usedItem.blade.php b/resources/views/home/usedItem.blade.php index 42f106e..e2b1baf 100644 --- a/resources/views/home/usedItem.blade.php +++ b/resources/views/home/usedItem.blade.php @@ -1,12 +1,15 @@ @if ($item->used_by == \Auth::id()) -
+ {{ csrf_field() }} + @method('DELETE')
{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}} + + @else