source: app/Http/Controllers/ManagerController.php

Last change on this file was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago
  • Initial commit;
  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[dfae77e]1<?php
2
3namespace App\Http\Controllers;
4
5use App\Models\Artist;
6use App\Models\Manager;
7use App\Models\Offer;
8use App\Models\User;
9use Illuminate\Http\Request;
10use Illuminate\Support\Facades\Auth;
11
12class ManagerController extends Controller
13{
14 public function __construct()
15 {
16 $this->middleware(['auth', 'verified', 'onboarding', 'role:manager']);
17 }
18
19 public function index()
20 {
21 $artists = Artist::where('manager_id', Auth::id())->get();
22
23 return view('web.manager.artists')
24 ->with('artists', $artists);
25 }
26
27 /**
28 * Display the specified resource.
29 *
30 * @param int $id
31 * @return Responsе|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\never
32 */
33 public function show($username)
34 {
35 $user = User::where('username', $username)->firstOrFail();
36
37 if (Auth::id() === $user->id) {
38 $managerProfile = Manager::with('user')
39 ->whereHas('user', function ($query) use ($username) {
40 return $query->where('username', '=', $username);
41 })->firstOrFail();
42
43 return view('web.manager.profile')
44 ->with('manager', $managerProfile);
45 }
46
47 return abort(404);
48 }
49
50
51}
Note: See TracBrowser for help on using the repository browser.