Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rBackend new #257

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEW BACKEND BRANCH
16 changes: 5 additions & 11 deletions app/Blog.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
<?php

namespace App;
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Blog extends Model
{
// Table Name
protected $table = 'blogs';
// Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;

public function user(){
return $this->belongsTo('App\User');
}
protected $fillable = [
'title',
'body'
];
}
10 changes: 7 additions & 3 deletions app/Contact.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php

namespace App;
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Contact extends Model
{
protected $fillable = [
'fname', 'lname', 'email','phone','message'
];
'first_name',
'last_name',
'email',
'phone',
'message'
];
}
4 changes: 2 additions & 2 deletions app/RegisteredCourse.php → app/CourseContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Illuminate\Database\Eloquent\Model;

class RegisteredCourse extends Model
class CourseContent extends Model
{
protected $guarded = [];
public function user(){
return $this->belongsTo(User::class);
return $this->belongsTo(Courses::class);
}
}
21 changes: 21 additions & 0 deletions app/Courses.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Courses extends Model
{
protected $guarded = [];
public function user(){
return $this->belongsTo(User::class);
}

public function reviews(){
return $this->hasMany(Reviews::class);
}

public function contents(){
return $this->hasMany(CourseContent::class);
}
}
8 changes: 3 additions & 5 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\User;
use App\Http\Controllers\Controller;

class AdminController extends Controller
{

public function __construct()
{
$this->middleware('auth');
Expand All @@ -20,8 +18,8 @@ public function __construct()
*/
public function index()
{
$mentors = User::where('role', '1')->get();
return view('admin.mentors')->with('mentors', $mentors);
$tutors = User::where('role', '1')->paginate(5);
return view('admin.tutors')->with('tutors', $tutors);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ class ForgotPasswordController extends Controller
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
20 changes: 1 addition & 19 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use App\User;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
Expand All @@ -27,23 +25,7 @@ class LoginController extends Controller
*
* @var string
*/
// protected $redirectTo = '/home';

protected function redirectTo()
{
$role = Auth::user()->role;
$email = Auth::user()->email;


if($role || $email=='[email protected]'){
return route('users');

}
return route('index');
//
// return view('frontend.frontend.admin');

}
protected $redirectTo = '/home';

/**
* Create a new controller instance.
Expand Down
28 changes: 2 additions & 26 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Auth;

class RegisterController extends Controller
{
/*
Expand All @@ -28,20 +28,7 @@ class RegisterController extends Controller
*
* @var string
*/
// protected $redirectTo = '/';
protected $registerView = 'frontend.frontend.register';

protected function redirectTo()
{
$role = Auth::user()->role;
$email = Auth::user()->email;
//use your own route
if(!$role){
return route('index');
}
return route('admin');

}
protected $redirectTo = '/home';

/**
* Create a new controller instance.
Expand All @@ -52,13 +39,7 @@ public function __construct()
{
$this->middleware('guest');
}
public function showRegistrationForm() {
return view('frontend.frontend.register');
}

public function showLoginForm() {
return view('frontend.frontend.register');
}
/**
* Get a validator for an incoming registration request.
*
Expand All @@ -67,13 +48,10 @@ public function showLoginForm() {
*/
protected function validator(array $data)
{

return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'phone'=>'',
'password' => ['required', 'string', 'min:8', 'confirmed'],

]);
}

Expand All @@ -88,9 +66,7 @@ protected function create(array $data)
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'phone' => $data['phone'],
'password' => Hash::make($data['password']),
'state' => $data['phone'],
]);
}
}
Loading