62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\School;
|
|
use App\Services\Invoice\InvoiceDataService;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use function auditionSetting;
|
|
use function redirect;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
protected InvoiceDataService $invoiceService;
|
|
|
|
public function __construct(InvoiceDataService $invoiceService)
|
|
{
|
|
$this->invoiceService = $invoiceService;
|
|
}
|
|
|
|
public function profile()
|
|
{
|
|
return view('dashboard.profile');
|
|
}
|
|
|
|
public function dashboard(
|
|
) {
|
|
return view('dashboard.dashboard');
|
|
// return view('dashboard.dashboard');
|
|
}
|
|
|
|
public function my_school()
|
|
{
|
|
if (Auth::user()->school) {
|
|
return redirect('/schools/'.Auth::user()->school->id);
|
|
}
|
|
$possibilities = Auth::user()->possibleSchools();
|
|
if (count($possibilities) < 1) {
|
|
return view('schools.create');
|
|
}
|
|
$schools = School::orderBy('name')->get();
|
|
|
|
return view('dashboard.select_school', ['possibilities' => $possibilities, 'schools' => $schools]);
|
|
}
|
|
|
|
public function my_invoice()
|
|
{
|
|
if (! Auth::user()->school_id) {
|
|
return redirect()->route('dashboard')->with('error', 'You do not have a school to get an invoice for');
|
|
}
|
|
|
|
if (! auditionSetting('invoicing_enabled')) {
|
|
return redirect()->route('dashboard')->with('error', 'Invoicing is not enabled');
|
|
}
|
|
|
|
$invoiceData = $this->invoiceService->allData(Auth::user()->school_id);
|
|
$school = Auth::user()->school;
|
|
|
|
return view('dashboard.invoice', compact('school', 'invoiceData'));
|
|
}
|
|
}
|