diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 0fd5af0..cffaf62 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,38 +2,30 @@ namespace App\Http\Controllers; +use App\SpotifyPlayActivity; use Illuminate\Contracts\Support\Renderable; -class HomeController extends Controller -{ - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('auth'); - } +class HomeController extends Controller { + + public function index(): Renderable { + $lastSpotifyTrack = SpotifyPlayActivity::with(['track', 'track.album', 'track.artists']) + ->where('user_id', auth()->user()->id) + ->orderBy('timestamp_start', 'DESC') + ->limit(1) + ->first(); - /** - * Show the application dashboard. - * - * @return Renderable - */ - public function index(): Renderable - { - return view('home'); + return view('home', [ + 'lastSpotifyTrack' => $lastSpotifyTrack + ]); } - public static function getCurrentGitHash(): string - { + public static function getCurrentGitHash(): string { try { $gitBasePath = base_path() . '/.git'; $gitStr = file_get_contents($gitBasePath . '/HEAD'); return rtrim(preg_replace("/(.*?\/){2}/", '', $gitStr)); - } catch (\Exception $e) { + } catch(\Exception $e) { report($e); return 'unknown'; } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index b7b6eed..63de419 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -7,22 +7,25 @@
-
Willkommen im neuen KStats
- @if (session('status')) - - @endif - -

Optisch kaum anders, aber im inner'n hat sich viel getan. Dies ist aktuell erst eine - "Vorab-Version", einige Features und Statistiken, die du vielleicht kennst sind aktuell noch - nicht Verfügbar, kommen aber bald zurück!

+ @isset($lastSpotifyTrack) + abgespielt {{$lastSpotifyTrack->timestamp_start->diffForHumans()}} + @endisset +
Dein zuletzt gehörter Track
+ @isset($lastSpotifyTrack) + @include('spotify.components.track', ['track' => $lastSpotifyTrack->track]) + @else +

+ Du hast bisher noch kein Lied auf Spotify gehört oder nutzt die KStats + Statistik nicht! :c +

+ @endisset
+

Verbundene Dienste