Laravel 2

<h1>User Controller</h1>

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\User;
use Redirect;
use Mail;
use Auth;

class UserController extends Controller
{
/* public function __construct()
{
if (!Auth::check())
{
return redirect()->to(‘/’);
}
}*/

public function Register()
{
return view(‘user.register’);
}

public function RegisterStore(Request $request)
{
$UserData = User::create([
‘name’=>$request->name,
‘role_id’=>$request->role,
’email’=>$request->email,
‘password’=>bcrypt($request->password),
‘verify_token’=>Str::random(40),
]);

//return $data;

Mail::send(‘mail.mail-ui’, [‘data’ => $UserData], function ($m) use ($UserData) {
$m->from(‘raminfotech13@gmail.com’, $UserData[‘name’]);
$m->to($UserData[’email’],’Blog Website’)->subject(‘This is email confirmation mail ‘);
});

return redirect(‘Login’)->with(‘msg’,’Now kindly Verify Your Email Address’);
}

public function VerifyUser($email, $verifytoken)
{
$UserData = User::where([’email’=>$email, ‘verify_token’=>$verifytoken])->first();

if($UserData)
{
$getData=User::where([’email’=>$email,’verify_token’=>$verifytoken])->update([‘status’=>’1’,’verify_token’=>NULL]);

return redirect(‘Login’)->with(‘msg’, ‘Thanks for verification’);
}
else
{
return ‘User Not Found’;
}
}

public function LogIn()
{
return view(‘user.login’);
}

public function LogInStore(Request $request){
$this->validate($request,[
’email’ => ‘required’,
‘password’ => ‘required’
]);
$credentials = [
’email’ => $request->email,
‘password’ => $request->password,
‘status’ => 1,
];

$auth = auth()->guard(‘web’);

if(!$auth->attempt($credentials))
{
return redirect(‘login-ui’)->with(‘msg’,’Sorry!!! details are incorrect.’);
}
else{

if (Auth::user()->role_id === 1)
{
return redirect(‘admin-panel’);
}

elseif (Auth::user()->role_id === 2)
{
return redirect(‘user-panel’);
}

elseif (Auth::user()->role_id === 3)
{
return redirect(‘admin-panel’);
}

}

}

public function Logout()
{
session()->flush();
return redirect(“login”);
}

public function UserPanel()
{
return view(‘user.user-dashboard’);
}

public function redirectTo()
{
$superAdmin = Auth::user()->type_id = 1;
$admin = Auth::user()->type_id = 2;
$cashier = Auth::user()->type_id = 3;

if ($superAdmin) {
return ‘/superAdmin/home’;
}
elseif ($admin) {
return ‘/admin/home’;
}
elseif ($cashier) {
return ‘/cashier/home’;
}
}

}

==================================================================================================

==================================================================================================

<h1>Middleware</h1>

<h3>Create New Check Amdin middle ware</h3>
public function handle($request, Closure $next)
{

//if (Auth::guard($guard)->check()) {
//return redirect(‘/home’);
// return Redirect::back();/*Ram*/
//}

//return $next($request);

if (auth()->check() && auth()->user()->role_id == 1)
{
return $next($request);
}
return Redirect::back();

/*
if (Auth::user()->role_id == 1)
{
return $next($request);
}*/

// return Redirect::back();

/*if (Auth::user()->role_id === 1)
{
return redirect(‘admin-panel’);
}*/
/*
if (!Auth::guard(‘web’)->check()) {
return redirect(‘login’);
}*/

//return $next($request);
}
}

<h3>Create New Check User middle ware</h3>

==================================================================================================

==================================================================================================

<h1>Kernel.php Page</h1>

protected $routeMiddleware = [
‘auth’ => \App\Http\Middleware\Authenticate::class,
‘auth.basic’ => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
‘bindings’ => \Illuminate\Routing\Middleware\SubstituteBindings::class,
‘cache.headers’ => \Illuminate\Http\Middleware\SetCacheHeaders::class,
‘can’ => \Illuminate\Auth\Middleware\Authorize::class,
‘guest’ => \App\Http\Middleware\RedirectIfAuthenticated::class,
‘signed’ => \Illuminate\Routing\Middleware\ValidateSignature::class,
‘throttle’ => \Illuminate\Routing\Middleware\ThrottleRequests::class,
‘verified’ => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

‘CheckAdmin’ => \App\Http\Middleware\CheckAdmin::class,

‘CheckUser’ => \App\Http\Middleware\CheckUser::class,
];

==================================================================================================

==================================================================================================
<h1>Page Web.php Routes</h1>

/*
|————————————————————————–
| Web Routes
|————————————————————————–
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the “web” middleware group. Now create something great!
|
*/

Route::get(‘/’, function () {
return view(‘welcome’);
});

Route::get(‘about-sir’, ‘comController@AboutUs’)->name(‘about-us’);
Route::get(‘contact-sir’, ‘comController@ContactUs’)->name(‘con-sir’);

Route::get(‘register’,’UserController@Register’)->middleware(‘guest’);

Route::post(‘register’,’UserController@RegisterStore’)->middleware(‘guest’);

Route::get(‘verify-user/{email}/{token}’,’UserController@VerifyUser’);

Route::get(‘login’,’UserController@LogIn’)->middleware(‘guest’);

Route::post(‘login’,’UserController@LogInStore’);

Route::group([‘middleware’ => [‘web’,’CheckAdmin’]], function () {
Route::get(‘admin-panel’, ‘AdminController@AdminPanel’);
});

Route::group([‘middleware’ => [‘web’,’CheckUser’]], function () {
Route::get(‘user-panel’, ‘UserController@UserPanel’);
});

Route::get(‘logout’,’UserController@Logout’);

==================================================================================================

==================================================================================================

<h1>View Admin</h1>

<h1>Admin Panel</h1>

<a href=”{{ url(‘logout’) }}”>Out</a>

<h2>{{Auth::user()}}</h2>
<h3>{{Auth::user()->name}}</h3>

==================================================================================================
<h1>Folder Mail mailer file</h1>

<!doctype html>
<html lang=”{{ app()->getLocale() }}”>
<head>
<meta charset=”utf-8″>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>

<title>Laravel</title>

<!– Fonts –>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>

<!– Styles –>

</head>
<body>
<br>
<br>
<br>
<div class=”container”>
<div class=”row”>
<h1>Kindly Confirm Your Email so that you can login into your account</h1>
<a href=”{{url(‘verify-user’)}}/{{$data[’email’]}}/{{$data[‘verify_token’]}}”>Click Here</a>
</div>
</div>
</body>
</html>
==================================================================================================

==================================================================================================

==================================================================================================

==================================================================================================

==================================================================================================

Leave a comment

Your email address will not be published. Required fields are marked *

How it works for an SEO

As we are into digital marketing for the past many years and we have worked on many web project to achieve the our goal so that we can provide the quality work for our clients, so we have few steps which we have mention below, so these are the steps on which we work to make our client happy.

Find Keywords

On page Optimization

Off page Optimization

Reach Target

How it works for Web Development

Web Designing and Development is very creative and logical things for this we have creative designer who understands our client requirements, as per that designing and development done by our developer who loves to play with code.


Designing

Development

Testing

Delivery

Why Choose Rank Lift Technologies

Rank Lift Technologies is a global information technology & seo company and well known as SEO Services India, we are very focused and committed to empowering business transformation of our client and we love seo marketing. These are facts that you will choose us as we are best seo company We work on our Client satisfaction which full filled their business goal, as we are very dedicated towards our work respect the punctuality of time delivery the project before deadline, full our commitment so that our client would not get disappointed.



Focus on Result

Strong Technical Team

Client Satisfaction

Trustworthy

No Hidden Cost

Contact us here