Cleanup
This commit is contained in:
parent
a9af6aaeb0
commit
faebb04d2c
|
|
@ -2,9 +2,66 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StudentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$students = Auth::user()->students();
|
||||
return view('students.index',['students' => $students]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
return $this->belongsTo(School::class);
|
||||
}
|
||||
|
||||
public function students(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Student::class, School::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of schools using the users email domiain
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
@props(['active' => false])
|
||||
|
||||
<a class="{{ $active ? 'bg-indigo-700' : 'hover:bg-indigo-500 hover:bg-opacity-75' }} text-white rounded-md px-3 py-2 text-sm font-medium"
|
||||
aria-current="{{ $active ? 'page':'false' }}"
|
||||
{{ $attributes }}
|
||||
>{{ $slot }}</a>
|
||||
|
|
@ -14,8 +14,11 @@
|
|||
<div class="hidden md:block">
|
||||
<div class="ml-10 flex items-baseline space-x-4">
|
||||
<!-- Current: "bg-indigo-700 text-white", Default: "text-white hover:bg-indigo-500 hover:bg-opacity-75" -->
|
||||
<a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>
|
||||
<a href="#" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>
|
||||
<x-layout.nav-link href="/dashboard" :active="request()->is('dashboard')">Dashboard</x-layout.nav-link>
|
||||
<x-layout.nav-link href="/students" :active="request()->is('students')">Students</x-layout.nav-link>
|
||||
{{-- <a href="/dashboard" class="bg-indigo-700 text-white rounded-md px-3 py-2 text-sm font-medium" aria-current="page">Dashboard</a>--}}
|
||||
|
||||
{{-- <a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 rounded-md px-3 py-2 text-sm font-medium">Students</a>--}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -137,7 +140,7 @@
|
|||
<div class="space-y-1 px-2 pb-3 pt-2 sm:px-3">
|
||||
<!-- Current: "bg-indigo-700 text-white", Default: "text-white hover:bg-indigo-500 hover:bg-opacity-75" -->
|
||||
<a href="/dashboard" class="bg-indigo-700 text-white block rounded-md px-3 py-2 text-base font-medium" aria-current="page">Dashboard</a>
|
||||
<a href="#" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 block rounded-md px-3 py-2 text-base font-medium">Students</a>
|
||||
<a href="/students" class="text-white hover:bg-indigo-500 hover:bg-opacity-75 block rounded-md px-3 py-2 text-base font-medium">Students</a>
|
||||
</div>
|
||||
<div class="border-t border-indigo-700 pb-3 pt-4">
|
||||
<div class="flex items-center px-5">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Students</x-slot:page_title>
|
||||
</x-layout.app>
|
||||
|
|
@ -2,12 +2,6 @@
|
|||
<x-layout.app>
|
||||
<x-slot:page_title>Test Page</x-slot:page_title>
|
||||
|
||||
<form method="POST" action="/users/32/set_school">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<input type="text" name="school_id" value="1">
|
||||
<button>Submit</button>
|
||||
</form>
|
||||
|
||||
{{ request()->is('test') ? 'yes':'no' }}
|
||||
|
||||
</x-layout.app>
|
||||
|
|
|
|||
|
|
@ -2,23 +2,35 @@
|
|||
|
||||
use App\Http\Controllers\DashboardController;
|
||||
use App\Http\Controllers\SchoolController;
|
||||
use App\Http\Controllers\StudentController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::view('/test','test');
|
||||
|
||||
Route::get('/dashboard', [DashboardController::class, 'dashboard']);
|
||||
Route::get('/profile', [DashboardController::class, 'profile']);
|
||||
Route::get('/my_school', [DashboardController::class, 'my_school']);
|
||||
|
||||
Route::patch('/users/{user}/set_school', [UserController::class, 'set_school']);
|
||||
Route::view('/test','test')->middleware('auth','verified');
|
||||
|
||||
Route::view('/','welcome')->middleware('guest');
|
||||
|
||||
// Dashboard Related Routes
|
||||
Route::middleware(['auth','verified'])->group(function () {
|
||||
Route::get('/dashboard', [DashboardController::class, 'dashboard']);
|
||||
Route::get('/profile', [DashboardController::class, 'profile']);
|
||||
Route::get('/my_school', [DashboardController::class, 'my_school']);
|
||||
Route::patch('/users/{user}/set_school', [UserController::class, 'set_school']);
|
||||
});
|
||||
|
||||
// Student Related Routes
|
||||
Route::middleware(['auth','verified'])->controller(StudentController::class)->group(function() {
|
||||
Route::get('/students','index');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// School Related Routes
|
||||
Route::middleware(['auth','verified'])->controller(SchoolController::class)->group(function() {
|
||||
// Route::get('/my_school','my_school');
|
||||
Route::get('/schools/create', 'create');
|
||||
Route::post('/schools','store');
|
||||
Route::get('/schools/{school}/edit','edit');
|
||||
|
|
|
|||
Loading…
Reference in New Issue