mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
Joining Take and Return controllers on just Take (store and delete)
This commit is contained in:
parent
b40a9fa3f1
commit
c4bd6a8a1a
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use \App\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReturnController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$item = User::find(\Auth::id())->items()->find(request('item'));
|
||||
$item->used_by = null;
|
||||
$item->save();
|
||||
|
||||
return redirect('home');
|
||||
}
|
||||
}
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header"><h3>Your items</h3></div>
|
||||
|
||||
<div class="card-header">Your items</div>
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
|
@ -1,12 +1,15 @@
|
||||
@if ($item->used_by == \Auth::id())
|
||||
<span class="float-right">
|
||||
<form action="/return" method="POST">
|
||||
<form action="/take" method="POST">
|
||||
{{ csrf_field() }}
|
||||
@method('DELETE')
|
||||
<input type="hidden" name="item" value="{{$item->id}}">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Return It</button>
|
||||
</form>
|
||||
</span>
|
||||
<span class="float-right mr-3"><em>{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em></span>
|
||||
|
||||
|
||||
@else
|
||||
<span class="float-right">
|
||||
<form action="/alert" method="POST">
|
||||
|
Loading…
Reference in New Issue
Block a user