login as lecturer

This commit is contained in:
Benjamin Takats
2022-12-01 11:23:15 +01:00
parent 9ec6b24a69
commit ba07dca294
20 changed files with 72 additions and 41 deletions

View File

@@ -8,16 +8,16 @@ created:
- database/factories/VenueFactory.php - database/factories/VenueFactory.php
- database/factories/EventFactory.php - database/factories/EventFactory.php
- database/factories/RegistrationFactory.php - database/factories/RegistrationFactory.php
- database/migrations/2022_11_30_170514_create_countries_table.php - database/migrations/2022_12_01_100450_create_countries_table.php
- database/migrations/2022_11_30_170515_create_cities_table.php - database/migrations/2022_12_01_100451_create_cities_table.php
- database/migrations/2022_11_30_170516_create_lecturers_table.php - database/migrations/2022_12_01_100452_create_lecturers_table.php
- database/migrations/2022_11_30_170517_create_participants_table.php - database/migrations/2022_12_01_100453_create_participants_table.php
- database/migrations/2022_11_30_170518_create_categories_table.php - database/migrations/2022_12_01_100454_create_categories_table.php
- database/migrations/2022_11_30_170519_create_courses_table.php - database/migrations/2022_12_01_100455_create_courses_table.php
- database/migrations/2022_11_30_170520_create_venues_table.php - database/migrations/2022_12_01_100456_create_venues_table.php
- database/migrations/2022_11_30_170521_create_events_table.php - database/migrations/2022_12_01_100457_create_events_table.php
- database/migrations/2022_11_30_170522_create_registrations_table.php - database/migrations/2022_12_01_100458_create_registrations_table.php
- database/migrations/2022_11_30_170523_create_category_course_table.php - database/migrations/2022_12_01_100459_create_category_course_table.php
- app/Models/Country.php - app/Models/Country.php
- app/Models/City.php - app/Models/City.php
- app/Models/Lecturer.php - app/Models/Lecturer.php

View File

@@ -24,18 +24,20 @@ class CreateNewUser implements CreatesNewUsers
public function create(array $input) public function create(array $input)
{ {
Validator::make($input, [ Validator::make($input, [
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => app()->environment('local') ? 'required' : $this->passwordRules(), 'password' => app()->environment('local') ? 'required' : $this->passwordRules(),
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '', 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
'is_lecturer' => ['required'],
]) ])
->validate(); ->validate();
return DB::transaction(function () use ($input) { return DB::transaction(function () use ($input) {
return tap(User::create([ return tap(User::create([
'name' => $input['name'], 'name' => $input['name'],
'email' => $input['email'], 'email' => $input['email'],
'password' => Hash::make($input['password']), 'password' => Hash::make($input['password']),
'is_lecturer' => $input['is_lecturer'] === 'on',
]), function (User $user) { ]), function (User $user) {
$this->createTeam($user); $this->createTeam($user);
}); });

View File

@@ -25,7 +25,10 @@ class User extends Authenticatable implements MustVerifyEmail
* @var string[] * @var string[]
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'name',
'email',
'password',
'is_lecturer',
]; ];
/** /**

View File

@@ -11,6 +11,7 @@ class Venue extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
*
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
@@ -22,10 +23,11 @@ class Venue extends Model
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
*
* @var array * @var array
*/ */
protected $casts = [ protected $casts = [
'id' => 'integer', 'id' => 'integer',
'city_id' => 'integer', 'city_id' => 'integer',
]; ];

View File

@@ -4,11 +4,9 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration {
{
/** /**
* Run the migrations. * Run the migrations.
*
* @return void * @return void
*/ */
public function up() public function up()
@@ -16,19 +14,24 @@ return new class extends Migration
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->string('email')->unique(); $table->string('email')
$table->timestamp('email_verified_at')->nullable(); ->unique();
$table->timestamp('email_verified_at')
->nullable();
$table->string('password'); $table->string('password');
$table->rememberToken(); $table->rememberToken();
$table->foreignId('current_team_id')->nullable(); $table->foreignId('current_team_id')
$table->string('profile_photo_path', 2048)->nullable(); ->nullable();
$table->string('profile_photo_path', 2048)
->nullable();
$table->boolean('is_lecturer')
->default(false);
$table->timestamps(); $table->timestamps();
}); });
} }
/** /**
* Reverse the migrations. * Reverse the migrations.
*
* @return void * @return void
*/ */
public function down() public function down()

View File

@@ -37,11 +37,13 @@ class DatabaseSeeder extends Seeder
'password' => bcrypt('1234'), 'password' => bcrypt('1234'),
'remember_token' => Str::random(10), 'remember_token' => Str::random(10),
]); ]);
Team::create([ $team = Team::create([
'name' => 'Admin Team', 'name' => 'Admin Team',
'user_id' => $user->id, 'user_id' => $user->id,
'personal_team' => true, 'personal_team' => true,
]); ]);
$user->current_team_id = $team->id;
$user->save();
Country::create([ Country::create([
'name' => 'Deutschland', 'name' => 'Deutschland',
'code' => 'de', 'code' => 'de',

View File

@@ -1,4 +1,5 @@
{ {
"I want to submit new courses on this platform": "Ich bin Dozent und möchte neue Kurse auf dieser Plattform einstellen",
"(and :count more error)": "(und :count weiterer Fehler)", "(and :count more error)": "(und :count weiterer Fehler)",
"(and :count more errors)": "(und :count weitere Fehler)", "(and :count more errors)": "(und :count weitere Fehler)",
"A fresh verification link has been sent to your email address.": "Ein neuer Bestätigungslink wurde an Ihre E-Mail-Adresse gesendet.", "A fresh verification link has been sent to your email address.": "Ein neuer Bestätigungslink wurde an Ihre E-Mail-Adresse gesendet.",
@@ -202,4 +203,4 @@
"You may not delete your personal team.": "Sie können Ihr persönliches Team nicht löschen.", "You may not delete your personal team.": "Sie können Ihr persönliches Team nicht löschen.",
"You may not leave a team that you created.": "Sie können ein von Ihnen erstelltes Team nicht verlassen.", "You may not leave a team that you created.": "Sie können ein von Ihnen erstelltes Team nicht verlassen.",
"Your email address is unverified.": "Ihre E-Mail-Adresse ist nicht verifiziert." "Your email address is unverified.": "Ihre E-Mail-Adresse ist nicht verifiziert."
} }

View File

@@ -37,6 +37,7 @@
</div> </div>
<div class="flex items-center justify-end mt-4"> <div class="flex items-center justify-end mt-4">
@if (Route::has('password.request')) @if (Route::has('password.request'))
<a class="underline text-sm text-gray-600 hover:text-gray-900" <a class="underline text-sm text-gray-600 hover:text-gray-900"
href="{{ route('password.request') }}"> href="{{ route('password.request') }}">
@@ -47,6 +48,7 @@
<x-jet-button class="ml-4"> <x-jet-button class="ml-4">
{{ __('Log in') }} {{ __('Log in') }}
</x-jet-button> </x-jet-button>
</div> </div>
</form> </form>
</x-jet-authentication-card> </x-jet-authentication-card>

View File

@@ -1,39 +1,55 @@
<x-guest-layout> <x-guest-layout>
<x-jet-authentication-card> <x-jet-authentication-card>
<x-slot name="logo"> <x-slot name="logo">
<x-jet-authentication-card-logo /> <x-jet-authentication-card-logo/>
</x-slot> </x-slot>
<x-jet-validation-errors class="mb-4" /> <x-jet-validation-errors class="mb-4"/>
<form method="POST" action="{{ route('register') }}"> <form method="POST" action="{{ route('register') }}">
@csrf @csrf
<div> <div>
<x-jet-label for="name" value="{{ __('Name') }}" /> <x-jet-label for="name" value="{{ __('Name') }}"/>
<x-jet-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required autofocus autocomplete="name" /> <x-jet-input id="name" class="block mt-1 w-full" type="text" name="name" :value="old('name')" required
autofocus autocomplete="name"/>
</div> </div>
<div class="mt-4"> <div class="mt-4">
<x-jet-label for="email" value="{{ __('Email') }}" /> <x-jet-label for="email" value="{{ __('Email') }}"/>
<x-jet-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required /> <x-jet-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')"
required/>
</div> </div>
<div class="mt-4"> <div class="mt-4">
<x-jet-label for="password" value="{{ __('Password') }}" /> <x-jet-label for="password" value="{{ __('Password') }}"/>
<x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" /> <x-jet-input id="password" class="block mt-1 w-full" type="password" name="password" required
autocomplete="new-password"/>
</div> </div>
<div class="mt-4"> <div class="mt-4">
<x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}" /> <x-jet-label for="password_confirmation" value="{{ __('Confirm Password') }}"/>
<x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password" name="password_confirmation" required autocomplete="new-password" /> <x-jet-input id="password_confirmation" class="block mt-1 w-full" type="password"
name="password_confirmation" required autocomplete="new-password"/>
</div>
<div class="mt-4">
<x-jet-label for="is_lecturer">
<div class="flex items-center">
<x-jet-checkbox name="is_lecturer" id="is_lecturer" required/>
<div class="ml-2">
{{ __('I want to submit new courses on this platform') }}
</div>
</div>
</x-jet-label>
</div> </div>
@if (Laravel\Jetstream\Jetstream::hasTermsAndPrivacyPolicyFeature()) @if (Laravel\Jetstream\Jetstream::hasTermsAndPrivacyPolicyFeature())
<div class="mt-4"> <div class="mt-4">
<x-jet-label for="terms"> <x-jet-label for="terms">
<div class="flex items-center"> <div class="flex items-center">
<x-jet-checkbox name="terms" id="terms" required /> <x-jet-checkbox name="terms" id="terms" required/>
<div class="ml-2"> <div class="ml-2">
{!! __('I agree to the :terms_of_service and :privacy_policy', [ {!! __('I agree to the :terms_of_service and :privacy_policy', [

View File

@@ -3,7 +3,7 @@
{{ $logo }} {{ $logo }}
</div> </div>
<div class="w-full sm:max-w-md mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg"> <div class="w-full sm:max-w-xl mt-6 px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
{{ $slot }} {{ $slot }}
</div> </div>
</div> </div>