diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
new file mode 100644
index 0000000..e9234c4
--- /dev/null
+++ b/app/Http/Controllers/DashboardController.php
@@ -0,0 +1,30 @@
+school) {
+ return redirect('/schools/' . Auth::user()->school->id);
+ }
+ $possibilities = Auth::user()->possibleSchools();
+ if (count($possibilities) < 1) return view('schools.create');
+ return view('dashboard.select_school', ['possibilities' => $possibilities]);
+ }
+}
diff --git a/app/Models/School.php b/app/Models/School.php
index ffb7cf2..9d6b9b2 100644
--- a/app/Models/School.php
+++ b/app/Models/School.php
@@ -20,4 +20,11 @@ class School extends Model
{
return $this->hasMany(SchoolEmailDomain::class);
}
+
+ public function initialLetterImageURL($bg_color = '4f46e5', $text_color='fff'): string
+ {
+ $img = "https://ui-avatars.com/api/?background=$bg_color&color=$text_color&name=";
+ $img .= substr($this->name,0,1);
+ return $img;
+ }
}
diff --git a/app/Models/SchoolEmailDomain.php b/app/Models/SchoolEmailDomain.php
index 1f5b40e..d69f1df 100644
--- a/app/Models/SchoolEmailDomain.php
+++ b/app/Models/SchoolEmailDomain.php
@@ -4,10 +4,16 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
class SchoolEmailDomain extends Model
{
use HasFactory;
protected $guarded = [];
public $timestamps = false;
+
+ public function school(): BelongsTo
+ {
+ return $this->belongsTo(School::class);
+ }
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 476c2e8..02104d7 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -6,6 +6,7 @@ namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -67,4 +68,25 @@ class User extends Authenticatable implements MustVerifyEmail
{
return $this->belongsTo(School::class);
}
+
+
+ /**
+ * Return an array of schools using the users email domiain
+ * @return SchoolEmailDomain[]
+ */
+ public function possibleSchools()
+ {
+ if ($this->school_id) {
+ $return[] = $this->school;
+ return $return;
+ }
+ return SchoolEmailDomain::with('school')->where('domain','=',$this->emailDomain())->get();
+// $x = SchoolEmailDomain::with('school')->where('domain','=',Auth::user()->emailDomain())->get();
+// $possibilities = SchoolEmailDomain::with('school')->where('domain','=', $this->emailDomain())->getModels();
+// $return = [];
+// foreach ($possibilities as $possibility) {
+// $return[] = $possibility->school;
+// }
+// return $return;
+ }
}
diff --git a/resources/views/components/card/card.blade.php b/resources/views/components/card/card.blade.php
new file mode 100644
index 0000000..6d95216
--- /dev/null
+++ b/resources/views/components/card/card.blade.php
@@ -0,0 +1,14 @@
+@props(['heading' => false, 'subheading' => false])
+
+ @if($heading)
+
+
{{ $heading }}
+ @if($subheading)
+
{{ $subheading }}
+ @endif
+
+ @endif
+
+ {{ $slot }}
+
+
diff --git a/resources/views/components/card/info/body.blade.php b/resources/views/components/card/info/body.blade.php
new file mode 100644
index 0000000..2413f98
--- /dev/null
+++ b/resources/views/components/card/info/body.blade.php
@@ -0,0 +1,5 @@
+
diff --git a/resources/views/components/info-card/row.blade.php b/resources/views/components/card/info/row.blade.php
similarity index 100%
rename from resources/views/components/info-card/row.blade.php
rename to resources/views/components/card/info/row.blade.php
diff --git a/resources/views/components/card/list/body.blade.php b/resources/views/components/card/list/body.blade.php
new file mode 100644
index 0000000..7452a06
--- /dev/null
+++ b/resources/views/components/card/list/body.blade.php
@@ -0,0 +1,9 @@
+@props(['view_all_href' => false])
+
+
+ @if($view_all_href)
+
View all
+ @endif
+
diff --git a/resources/views/components/card/list/row-image.blade.php b/resources/views/components/card/list/row-image.blade.php
new file mode 100644
index 0000000..ce5d106
--- /dev/null
+++ b/resources/views/components/card/list/row-image.blade.php
@@ -0,0 +1,4 @@
+@php
+ $img_classes = "h-12 w-12 flex-none rounded-full bg-gray-50";
+@endphp
+
merge(['class' => $img_classes]) }}>
diff --git a/resources/views/components/card/list/row-text-subtext.blade.php b/resources/views/components/card/list/row-text-subtext.blade.php
new file mode 100644
index 0000000..5140bdd
--- /dev/null
+++ b/resources/views/components/card/list/row-text-subtext.blade.php
@@ -0,0 +1,6 @@
+
+
{{ $slot }}
+ @if(isset($subtext))
+
{{ $subtext }}
+ @endif
+
diff --git a/resources/views/components/card/list/row.blade.php b/resources/views/components/card/list/row.blade.php
new file mode 100644
index 0000000..ef29e0c
--- /dev/null
+++ b/resources/views/components/card/list/row.blade.php
@@ -0,0 +1,10 @@
+
+
+ {{ $slot }}
+
+ @if(isset($right_link_button))
+ attributes->merge(['class' => 'rounded-full bg-white px-2.5 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50']) }}>
+ {{ $right_link_button }}
+
+ @endif
+
diff --git a/resources/views/components/info-card/card.blade.php b/resources/views/components/info-card/card.blade.php
deleted file mode 100644
index 3e956fe..0000000
--- a/resources/views/components/info-card/card.blade.php
+++ /dev/null
@@ -1,12 +0,0 @@
-@props(['heading' => false, 'subheading' => false])
-
- @if($heading)
- @include('components.info-card.header', ['heading' => $heading, 'subheading' => $subheading])
- @endif
-
-
-
diff --git a/resources/views/components/info-card/header.blade.php b/resources/views/components/info-card/header.blade.php
deleted file mode 100644
index d4af6d1..0000000
--- a/resources/views/components/info-card/header.blade.php
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
{{ $heading }}
- @if($subheading)
-
{{ $subheading }}
- @endif
-
diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard/dashboard.blade.php
similarity index 100%
rename from resources/views/dashboard.blade.php
rename to resources/views/dashboard/dashboard.blade.php
diff --git a/resources/views/profile.blade.php b/resources/views/dashboard/profile.blade.php
similarity index 100%
rename from resources/views/profile.blade.php
rename to resources/views/dashboard/profile.blade.php
diff --git a/resources/views/dashboard/select_school.blade.php b/resources/views/dashboard/select_school.blade.php
new file mode 100644
index 0000000..b60890a
--- /dev/null
+++ b/resources/views/dashboard/select_school.blade.php
@@ -0,0 +1,23 @@
+@php use Illuminate\Support\Facades\Auth; @endphp
+@php $school = Auth::user()->school; @endphp
+
+ Choose School
+
+
+
+ @foreach($possibilities as $possibility)
+ @php $school = $possibility->school; @endphp
+
+
+
+ {{ $school->name }}
+ {{ $school->city }}, {{ $school->state }}
+
+
+ @endforeach
+
+
+
diff --git a/resources/views/my_school.blade.php b/resources/views/my_school.blade.php
deleted file mode 100644
index 073a9bb..0000000
--- a/resources/views/my_school.blade.php
+++ /dev/null
@@ -1,12 +0,0 @@
-@php use Illuminate\Support\Facades\Auth; @endphp
-@php $school = Auth::user()->school; @endphp
-
- My School
-
-
diff --git a/resources/views/schools/show.blade.php b/resources/views/schools/show.blade.php
index c7fffc1..0a40fa2 100644
--- a/resources/views/schools/show.blade.php
+++ b/resources/views/schools/show.blade.php
@@ -1,37 +1,37 @@
School Info - {{ $school->name }}
-
-
-
-
- {{ $school->name }}
- {{ $school->address }}
- {{ $school->city }}, {{ $school->state }} {{ $school->zip }}
+
+
+
+
+
+ {{ $school->name }}
+ {{ $school->address }}
+ {{ $school->city }}, {{ $school->state }} {{ $school->zip }}
+
+
-
-
-
+
-
-
- @foreach($school->directors as $director)
- - {{ $director->full_name() }} - {{ $director->email }}
- @endforeach
-
-
+
+
+ @foreach($school->directors as $director)
+ - {{ $director->full_name() }} - {{ $director->email }}
+ @endforeach
+
+
-
-
- @foreach($school->emailDomains as $domain)
- - {{ $domain->domain }}
- @endforeach
-
-
-
-
-
+
+
+ @foreach($school->emailDomains as $domain)
+ - {{ $domain->domain }}
+ @endforeach
+
+
+
+
diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php
index 04c053a..c22cbed 100644
--- a/resources/views/test.blade.php
+++ b/resources/views/test.blade.php
@@ -1,9 +1,12 @@
-@php use App\Models\School;use App\Models\User; @endphp
+@php use App\Models\School;use App\Models\SchoolEmailDomain;use App\Models\User;use Illuminate\Support\Facades\Auth; @endphp
Test Page
@php
- $school = School::first()->emailDomains->pluck('domain');
- dd($school);
+ $x = SchoolEmailDomain::with('school')->where('domain','=',Auth::user()->emailDomain())->get();
+ foreach ($x as $y)
+ {
+ echo "" . $y->school->name . "
";
+ }
@endphp
diff --git a/routes/web.php b/routes/web.php
index b21fde3..a3f2bfa 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,18 +1,20 @@
middleware('guest');
-Route::view('/profile','profile')->middleware('auth','verified');
-Route::view('/dashboard', 'dashboard')->middleware('auth', 'verified');
Route::middleware(['auth','verified'])->controller(SchoolController::class)->group(function() {
- Route::get('/my_school','my_school');
+ // Route::get('/my_school','my_school');
Route::get('/schools/create', 'create');
Route::post('/schools','store');
Route::get('/schools/{school}/edit','edit');