Skip to content

Commit

Permalink
Merge pull request #1 from danivideda/master
Browse files Browse the repository at this point in the history
test
  • Loading branch information
fariqkr authored Nov 28, 2020
2 parents 8a0ffc2 + 323fbc8 commit 351ecdd
Show file tree
Hide file tree
Showing 25 changed files with 1,094 additions and 145 deletions.
17 changes: 16 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,20 @@

class LoginController extends Controller
{
//
public function showStudentLoginForm() {
return view('auth.login-student');
}

public function showTeacherLoginForm() {
return view('auth.login-teacher');
}

public function loginStudent(Request $request) {
//
}

public function loginTeacher(Request $request) {
//
}

}
43 changes: 43 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Models\Student;
use App\Models\Teacher;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;

class RegisterController extends Controller
{
Expand All @@ -14,4 +18,43 @@ public function showStudentRegisterForm() {
public function showTeacherRegisterForm() {
return view('auth.register-teacher');
}

public function registerStudent(Request $request) {
$this->validate($request, [
'name' => 'required|max:255',
'email' => 'required|email|unique:students|max:255',
'password' => 'required|confirmed',
]);

Student::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password)
]);

Auth::guard('student')->attempt($request->only('email', 'password'));

return redirect()->route('student.dashboard');
}

public function registerTeacher(Request $request) {
$this->validate($request, [
'name' => 'required|max:255',
'school_name' => 'required|max:255',
'email' => 'required|email|unique:teachers|max:255',
'password' => 'required|confirmed',
]);

Teacher::create([
'name' => $request->name,
'school_name' => $request->school_name,
'email' => $request->email,
'password' => Hash::make($request->password)
]);

Auth::guard('teacher')->attempt($request->only('email', 'password'));

return redirect()->route('teacher.dashboard');

}
}
76 changes: 2 additions & 74 deletions app/Http/Controllers/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,79 +6,7 @@

class StudentController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
public function index() {
return view('student.dashboard');
}
}
12 changes: 12 additions & 0 deletions app/Http/Controllers/TeacherController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TeacherController extends Controller
{
public function index() {
return view('teacher.dashboard');
}
}
1 change: 1 addition & 0 deletions app/Models/Student.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Student extends Authenticatable

protected $casts = [
'classroom_joined' => 'array',
'email_verified_at' => 'datetime',
];

}
29 changes: 29 additions & 0 deletions app/Models/Teacher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Model;

class Teacher extends Authenticatable
{
use HasFactory;

protected $fillable = [
'name',
'school_name',
'email',
'password'
];

protected $hidden = [
'password',
'remember_token',
];

protected $casts = [
'classroom_teached' => 'array',
'email_verified_at' => 'datetime',
];
}
25 changes: 25 additions & 0 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
'driver' => 'session',
'provider' => 'students',
],

'teacher' => [
'driver' => 'session',
'provider' => 'teachers',
],
],

/*
Expand Down Expand Up @@ -80,6 +85,12 @@
'driver' => 'eloquent',
'model' => App\Models\Student::class,
],

'teachers' => [
'driver' => 'eloquent',
'model' => App\Models\Teacher::class,
],

// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
Expand Down Expand Up @@ -108,6 +119,20 @@
'expire' => 60,
'throttle' => 60,
],

'students' => [
'provider' => 'students',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],

'teachers' => [
'provider' => 'teachers',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function up()
Schema::create('students', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('username')->unique();
$table->string('email')->unique();
$table->json('classroom_joined')->nullable();
$table->timestamp('email_verified_at')->nullable();
Expand Down
38 changes: 38 additions & 0 deletions database/migrations/2020_11_26_234638_create_teachers_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTeachersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('teachers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('school_name');
$table->string('email')->unique();
$table->json('classroom_teached')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('teachers');
}
}
Binary file added public/img/logo.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@extends('layouts.app')

@section('content')

<section class="bg-gradient-to-r from-blue-300 to-green-400 pt-12 pb-16 md:pt-8 px-8 h-screen" id="login">
<div class="container mx-auto flex flex-wrap flex-col md:flex-row items-center px-10">
<div class="w-full xl:w-7/12 py-6 overflow-y-hidden">
<img class="w-5/6 lg:mr-0" src="http://www.pngall.com/wp-content/uploads/5/Learning-PNG-Free-Download.png">
</div>
<div class="flex flex-col w-full xl:w-5/12 justify-center overflow-y-hidden">
<div class="bg-blue-500 px-4 py-8">
<span class="text-black font-extrabold text-center text-3xl inline mx-9"> LOGIN </span>
<p class="text-black font-extrabold text-center text-3xl inline mx-9 "> | </p>
<a class="text-gray-600 font-extrabold text-center text-3xl inline mx-9" href="{{ route('register.student') }}"> SIGN UP </a>
</div>
<div class="bg-white py-16 px-20">
<form action="" method="post">
@csrf
<div class="mb-4">
<label for="email" class="sr-only">Email</label>
<input type="text" name="email" id="email" placeholder="Email"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('email') border-red-500 @enderror" value="{{ old('email') }}">

@error('email')
<div class="text-red-500 mt-2 text-sm">
{{ $message }}
</div>
@enderror
</div>

<div class="mb-4">
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" id="password" placeholder="Password"
class="bg-gray-100 border-2 w-full p-4 rounded-lg @error('password') border-red-500 @enderror" value="">

@error('password')
<div class="text-red-500 mt-2 text-sm">
{{ $message }}
</div>
@enderror
</div>
<div>
<button type="submit" class="bg-pink-600 text-white px-4 py-3 rounded font-medium w-full">Login</button>
</div>
</form>
</div>
</div>
</div>
</section>

@endsection
Loading

0 comments on commit 351ecdd

Please sign in to comment.