Choosing a school working
This commit is contained in:
parent
e3a12c4ce5
commit
06dd3ba574
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use function redirect;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_school(Request $request, User $user)
|
||||||
|
{
|
||||||
|
request()->validate([
|
||||||
|
'school_id' => ['required','integer','exists:schools,id']
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'school_id' => request('school_id')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// TODO we probably don't want to go here if done from an admin page
|
||||||
|
return redirect('/my_school');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,11 @@
|
||||||
<x-card.list.body>
|
<x-card.list.body>
|
||||||
@foreach($possibilities as $possibility)
|
@foreach($possibilities as $possibility)
|
||||||
@php $school = $possibility->school; @endphp
|
@php $school = $possibility->school; @endphp
|
||||||
|
|
||||||
|
<form method="POST" action="/users/{{ Auth::user()->id }}/set_school">
|
||||||
|
@csrf
|
||||||
|
@method('PATCH')
|
||||||
|
<input type="hidden" name="school_id" id="school_id" value="{{ $school->id }}">
|
||||||
<x-card.list.row right_link_button_type="button">
|
<x-card.list.row right_link_button_type="button">
|
||||||
<x-card.list.row-image
|
<x-card.list.row-image
|
||||||
src="{{ $school->initialLetterImageURL() }}"
|
src="{{ $school->initialLetterImageURL() }}"
|
||||||
|
|
@ -18,8 +23,11 @@
|
||||||
{{ $school->name }}
|
{{ $school->name }}
|
||||||
<x-slot:subtext>{{ $school->city }}, {{ $school->state }}</x-slot:subtext>
|
<x-slot:subtext>{{ $school->city }}, {{ $school->state }}</x-slot:subtext>
|
||||||
</x-card.list.row-text-subtext>
|
</x-card.list.row-text-subtext>
|
||||||
<x-slot:right_link_button>Choose</x-slot:right_link_button>
|
<x-slot:right_link_button
|
||||||
|
onclick="return confirm('Please confirm you are a director at {{ $school->name }}');"
|
||||||
|
>Choose</x-slot:right_link_button>
|
||||||
</x-card.list.row>
|
</x-card.list.row>
|
||||||
|
</form>
|
||||||
@endforeach
|
@endforeach
|
||||||
</x-card.list.body>
|
</x-card.list.body>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,17 @@
|
||||||
|
|
||||||
use App\Http\Controllers\DashboardController;
|
use App\Http\Controllers\DashboardController;
|
||||||
use App\Http\Controllers\SchoolController;
|
use App\Http\Controllers\SchoolController;
|
||||||
|
use App\Http\Controllers\UserController;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::view('/test','test');
|
Route::view('/test','test');
|
||||||
|
|
||||||
Route::get('dashboard', [DashboardController::class, 'dashboard']);
|
Route::get('/dashboard', [DashboardController::class, 'dashboard']);
|
||||||
Route::get('profile', [DashboardController::class, 'profile']);
|
Route::get('/profile', [DashboardController::class, 'profile']);
|
||||||
Route::get('my_school', [DashboardController::class, 'my_school']);
|
Route::get('/my_school', [DashboardController::class, 'my_school']);
|
||||||
|
|
||||||
|
Route::patch('/users/{user}/set_school', [UserController::class, 'set_school']);
|
||||||
|
|
||||||
Route::view('/','welcome')->middleware('guest');
|
Route::view('/','welcome')->middleware('guest');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue