mirror of
https://github.com/brunofontes/shareit.git
synced 2025-11-15 07:50:54 -03:00
Including occupied username and renaming DB field
Now it shows the username of who is using an item. Item db field 'usedBy' was renamed to 'used_by' to keep consistence.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use \App\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
@@ -23,7 +24,17 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = \App\User::find(\Auth::id())->items()->get();
|
||||
return view('home', compact('items'));
|
||||
$items = User::find(\Auth::id())->items()->get();
|
||||
foreach ($items as $item) {
|
||||
|
||||
if ($item->used_by) {
|
||||
$users[$item->used_by] = User::find($item->used_by)->name;
|
||||
|
||||
if ($item->waiting_user_id) {
|
||||
$users[$item->waiting_user_id] = User::find($item->waiting_user_id)->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return view('home', compact('items', 'users'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user