mirror of
https://github.com/brunofontes/shareit.git
synced 2025-04-11 06:40:48 +00:00
Refreshing and Including number of used items on Title
It was necessary to keep refreshing the page to check if an item was returned when we did not want to be alerted. So, now, the page refresh itself every 2 minutes (while I do not know how to use Laravel broadcasting) and the title shows the number of items in use (including when used by you).
This commit is contained in:
parent
8c4fe0a489
commit
7a8d5ccaff
@ -28,7 +28,11 @@ class HomeController extends Controller
|
|||||||
{
|
{
|
||||||
$items = User::loggedIn()->items()->with('users')->get();
|
$items = User::loggedIn()->items()->with('users')->get();
|
||||||
|
|
||||||
|
$numberOfUsedItems = 0;
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
|
if (isset($item->used_by)) {
|
||||||
|
$numberOfUsedItems++;
|
||||||
|
}
|
||||||
$this->getUsername($item->users, $item->used_by);
|
$this->getUsername($item->users, $item->used_by);
|
||||||
$this->getUsername($item->users, $item->waiting_user_id);
|
$this->getUsername($item->users, $item->waiting_user_id);
|
||||||
}
|
}
|
||||||
@ -39,7 +43,7 @@ class HomeController extends Controller
|
|||||||
|
|
||||||
return view(
|
return view(
|
||||||
'home',
|
'home',
|
||||||
['products' => $products, 'users' => $this->activeUsers]
|
['products' => $products, 'users' => $this->activeUsers, 'usedItems' => $numberOfUsedItems]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
@extends('layouts.app')
|
@extends('layouts.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
setInterval(function() {
|
||||||
|
window.location.reload(true);
|
||||||
|
}, 2*60000); //NOTE: period is passed in milliseconds
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<!-- CSRF Token -->
|
<!-- CSRF Token -->
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
|
||||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
<title>{{ config('app.name', 'Laravel') }} {{ $usedItems ? "(${usedItems})" : '' }}</title>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
<script src="{{ asset('js/app.js') }}" defer></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user