Skip to content

Commit

Permalink
Merge branch 'main' into client_module
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafin31 committed Jul 2, 2021
2 parents 0134efe + 911dd4e commit dfc3e61
Show file tree
Hide file tree
Showing 33 changed files with 1,945 additions and 907 deletions.
55 changes: 55 additions & 0 deletions app/Exports/UsersExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Exports;

use App\Models\usersModel;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithEvents;

class UsersExport implements
FromCollection,
ShouldAutoSize,
WithHeadings,
WithEvents
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return usersModel::all();
}

public function headings(): array
{
return [
'Id',
'name',
'email',
'address',
'phone',
'Profile picture',
'type',
'status',
];
}

public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getStyle('A1:H1')->applyFromArray([
'font' => [
'bold' => true
]
]);
}
];
}
}
37 changes: 36 additions & 1 deletion app/Http/Controllers/loginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function loginVarify(loginForm $req)
$user = loginModel::where('user_name', $user_name)
->first();

if (Hash::check($req->password, $user['password'])) {
//checking users
if ($user) {
//checking account status
if ($user['account_Status'] == 'pending') {


$req->session()->put('status', true);
$req->session()->put('user_name', $req->user_name);
Expand All @@ -41,6 +45,37 @@ public function loginVarify(loginForm $req)

elseif($user['user_type'] == 'clients'){
return redirect()->route('client.index'); //client

$req->session()->flash('msg', 'Your account is in pending');
return redirect()->route('login.login');
} elseif ($user['account_Status'] == 'Block') {

$req->session()->flash('msg', 'Your account is Blocked');
return redirect()->route('login.login');
} else {

if (Hash::check($req->password, $user['password'])) {
if ($user['user_type'] == 'admin') {
$req->session()->put('status', true);
$req->session()->put('user_name', $req->user_name);
$req->session()->put('user_id', $user['id']);
$req->session()->put('user_type', $user['user_type']);
return redirect()->route('user.dashbord');
} elseif ($user['user_type'] == 'clients') {
//code
} elseif ($user['user_type'] == 'bank_manager') {
//code
} elseif ($user['user_type'] == 'noney_exchange_officer') {
//code
} else {
$req->session()->flash('msg', 'invaild request');
return redirect()->route('login.login');
}
} else {
$req->session()->flash('msg', 'invaild User Name or password');
return redirect()->route('login.login');
}

}
} else {
$req->session()->flash('msg', 'invaild User Name or password');
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/registrationcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function registration(registrationForm $req)
$user->phone_number = $req->phone_number;
$user->profile_picture = 'null';
$user->user_type = $req->user_type;
$user->account_Status = 'active';
$user->account_Status = 'pending';
$user->save();

$list = usersModel::all()->last();
Expand All @@ -37,6 +37,7 @@ public function registration(registrationForm $req)
$login->user_name = $req->user_name;
$login->password = bcrypt($req->password);
$login->user_type = $req->user_type;
$login->account_Status = 'pending';
$login->save();
DB::commit();
return redirect()->route('login.login');
Expand Down
Loading

0 comments on commit dfc3e61

Please sign in to comment.