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