diff --git a/app/Http/Controllers/StudentController.php b/app/Http/Controllers/StudentController.php
index 51be547..b4bf502 100644
--- a/app/Http/Controllers/StudentController.php
+++ b/app/Http/Controllers/StudentController.php
@@ -2,10 +2,13 @@
namespace App\Http\Controllers;
+use App\Models\School;
use App\Models\Student;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
+use function abort;
+use function redirect;
class StudentController extends Controller
{
@@ -54,16 +57,31 @@ class StudentController extends Controller
/**
* Update the specified resource in storage.
*/
- public function update(Request $request, User $user)
+ public function update(Request $request, Student $student)
{
- //
+ if ($request->user()->cannot('update', $student)) abort(403);
+ request()->validate([
+ 'first_name' => ['required'],
+ 'last_name' => ['required'],
+ 'grade' => ['required', 'integer'],
+ ]);
+
+ $student->update([
+ 'first_name' => request('first_name'),
+ 'last_name' => request('last_name'),
+ 'grade' => request('grade')
+ ]);
+
+ return redirect('/students');
}
/**
* Remove the specified resource from storage.
*/
- public function destroy(User $user)
+ public function destroy(Request $request, Student $student)
{
- //
+ if ($request->user()->cannot('delete', $student)) abort(403);
+ $student->delete();
+ return redirect('/students');
}
}
diff --git a/app/Models/Student.php b/app/Models/Student.php
index 51ce1ec..794148b 100644
--- a/app/Models/Student.php
+++ b/app/Models/Student.php
@@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
+
class Student extends Model
{
use HasFactory;
-
+ protected $guarded = [];
public function school(): BelongsTo
{
return $this->belongsTo(School::class);
diff --git a/app/Policies/StudentPolicy.php b/app/Policies/StudentPolicy.php
index 6d1304b..7d8fbb1 100644
--- a/app/Policies/StudentPolicy.php
+++ b/app/Policies/StudentPolicy.php
@@ -53,7 +53,7 @@ class StudentPolicy
*/
public function delete(User $user, Student $student): bool
{
- //
+ return $user->school_id == $student->school_id;
}
/**
diff --git a/app/helpers.php b/app/helpers.php
new file mode 100644
index 0000000..740ea8a
--- /dev/null
+++ b/app/helpers.php
@@ -0,0 +1,21 @@
+ "max-w-xs",
+ 'sm' => 'max-w-sm',
+ 'md' => 'max-w-md',
+ 'lg' => 'max-w-lg',
+ 'xl' => 'max-w-xl',
+ '2xl' => 'max-w-2xl',
+ '3xl' => 'max-w-3xl',
+ '4xl' => 'max-w-4xl',
+ '5xl' => 'max-w-5xl',
+ '6xl' => 'max-w-6xl',
+ '7xl' => 'max-w-7xl',
+ 'full' => 'max-w-full',
+ 'fit' => 'max-w-fit',
+ 'min' => 'max-w-min',
+ 'max' => 'max-w-max',
+ ];
+ return $return;
+}
diff --git a/composer.json b/composer.json
index 0805ff7..783de78 100644
--- a/composer.json
+++ b/composer.json
@@ -22,6 +22,9 @@
"spatie/laravel-ignition": "^2.4"
},
"autoload": {
+ "files": [
+ "app/helpers.php"
+ ],
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
diff --git a/resources/views/components/card/card.blade.php b/resources/views/components/card/card.blade.php
index f1251bc..b3eaafb 100644
--- a/resources/views/components/card/card.blade.php
+++ b/resources/views/components/card/card.blade.php
@@ -1,13 +1,6 @@
-@props(['mw' => false])
@php
$wrapper_classes = 'overflow-hidden bg-white shadow sm:rounded-lg';
- if ($mw) {
- $wrapper_classes .= ' mx-auto max-w-' . $mw;
- }
@endphp
merge(['class' => $wrapper_classes]) }}>
-
-
{{ $slot }}
-
diff --git a/resources/views/components/form/field.blade.php b/resources/views/components/form/field.blade.php
index 2f69e7b..bd7a6d0 100644
--- a/resources/views/components/form/field.blade.php
+++ b/resources/views/components/form/field.blade.php
@@ -37,7 +37,5 @@
@elseif($label_text)
{{ $label_text }}
@endif
-
- merge($inputAttributes) }}>
-
+ merge($inputAttributes) }}>
diff --git a/resources/views/dashboard/select_school.blade.php b/resources/views/dashboard/select_school.blade.php
index f9092dd..0adfeef 100644
--- a/resources/views/dashboard/select_school.blade.php
+++ b/resources/views/dashboard/select_school.blade.php
@@ -4,36 +4,38 @@
Choose School
{{-- --}}
-
-
- Choose your school
-
- Based on your email address, one of these schools may be yours
-
-
+
+
+
+ Choose your school
+
+ Based on your email address, one of these schools may be yours
+
+
-
- @foreach($possibilities as $possibility)
- @php $school = $possibility->school; @endphp
+
+ @foreach($possibilities as $possibility)
+ @php $school = $possibility->school; @endphp
-
- @endforeach
-
-
+
+ @endforeach
+
+
+
diff --git a/resources/views/schools/edit.blade.php b/resources/views/schools/edit.blade.php
index 3af4da2..2502a2f 100644
--- a/resources/views/schools/edit.blade.php
+++ b/resources/views/schools/edit.blade.php
@@ -1,20 +1,22 @@
-
-
- Edit School
-
+
+
+
+ Edit School
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
{{--
diff --git a/resources/views/schools/show.blade.php b/resources/views/schools/show.blade.php
index c3d83aa..df818e2 100644
--- a/resources/views/schools/show.blade.php
+++ b/resources/views/schools/show.blade.php
@@ -1,37 +1,39 @@
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/students/edit.blade.php b/resources/views/students/edit.blade.php
index bedf84e..1b77c5b 100644
--- a/resources/views/students/edit.blade.php
+++ b/resources/views/students/edit.blade.php
@@ -1,5 +1,14 @@
-
- boo
-
+
+
+ Edit Student
+
+
+
+
+
+
+
+
+
diff --git a/resources/views/students/index.blade.php b/resources/views/students/index.blade.php
index c7b408a..844ec90 100644
--- a/resources/views/students/index.blade.php
+++ b/resources/views/students/index.blade.php
@@ -11,11 +11,11 @@
Add Student
-
+
{{-- TODO make grade a dropdown --}}
- Save
+ Save
@@ -41,6 +41,16 @@
{{ $student->grade }}
Edit
+ |
+
+
+
@endforeach
@@ -50,18 +60,3 @@
-
-
-
-{{--
--}}
-{{-- Students --}}
-
-{{-- --}}
-{{-- Create Student --}}
-{{-- Student full names must be unique. Add a middle initial to the first name if necessary. --}}
-{{-- --}}
-{{-- --}}
-{{-- --}}
-{{-- --}}
-{{-- --}}
-{{-- --}}
diff --git a/resources/views/test.blade.php b/resources/views/test.blade.php
index dc47540..19b05bf 100644
--- a/resources/views/test.blade.php
+++ b/resources/views/test.blade.php
@@ -2,7 +2,7 @@
Test Page
-
+
Users
A list of all the users in your account including their name, title, email and role.
diff --git a/routes/web.php b/routes/web.php
index 78dfdca..1240305 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -28,6 +28,8 @@ Route::middleware(['auth','verified'])->controller(UserController::class)->group
Route::middleware(['auth','verified'])->controller(StudentController::class)->group(function() {
Route::get('/students','index');
Route::get('/students/{student}/edit','edit');
+ Route::patch('/students/{student}','update');
+ Route::delete('/students/{student}', 'destroy');
});
diff --git a/tailwind.config.js b/tailwind.config.js
index 5ffdb41..b33e723 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -5,6 +5,9 @@ export default {
"./resources/**/*.js",
"./resources/**/*.vue",
],
+ safelist: [
+ { pattern: /max-w-(xs|sm|md|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl)/ },
+ ],
theme: {
extend: {},
},