Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_DATABASE=fellow-admin
DB_USERNAME=root
DB_PASSWORD=

Expand Down
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/FellowShipSMSSystemAPI.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added .rnd
Binary file not shown.
4 changes: 4 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();

/* DB::table('users')->where('created_at', '<=', Carbon::now()
->subDay())->delete();
}*/
}

/**
Expand Down
10 changes: 10 additions & 0 deletions app/Contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Contact extends Model
{
protected $primaryKey = 'contact_id';
}
10 changes: 10 additions & 0 deletions app/ContactGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ContactGroup extends Model
{
//
}
18 changes: 18 additions & 0 deletions app/Exports/GroupExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Exports;

use App\GroupContact;
use Maatwebsite\Excel\Concerns\FromCollection;

class GroupExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return GroupContact::all();
}

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

namespace App\Exports;

use App\Contact;
use Maatwebsite\Excel\Concerns\FromCollection;

class UsersExport implements FromCollection
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Contact::all();
}
}
10 changes: 10 additions & 0 deletions app/FellowMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class FellowMessages extends Model
{
//
}
10 changes: 10 additions & 0 deletions app/Fellowship.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class fellowship extends Model
{
protected $primaryKey = 'fellow_id';
}
10 changes: 10 additions & 0 deletions app/GroupContact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class GroupContact extends Model
{
protected $primaryKey = 'Id';
}
11 changes: 11 additions & 0 deletions app/GroupMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class GroupMessage extends Model
{
protected $primaryKey = 'id';
}

10 changes: 10 additions & 0 deletions app/Http/Controllers/AddFellowshipController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AddFellowshipController extends Controller
{
//
}
88 changes: 88 additions & 0 deletions app/Http/Controllers/Api/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use App\Fellowship;
use App\user_role;
use App\User;
use App\Role;

class AuthController extends Controller
{

public function login(){

// ---------->>>>>>>>>>><<<<<<<<<<<-------------

try{
$credentials = request()->only('email','password');
$rules = [
'email' => 'required|max:255',
'password' => 'required|min:4'];
$validator = Validator::make($credentials, $rules);

if($validator->fails()){
$error = $validator->messages();
return response()->json(['status'=>false, 'result'=>null, 'message'=>null, 'error'=> $error],500);
}
if(!Auth::attempt($credentials)) {
// return response()->json(['status'=>false, 'result'=>null, 'message'=>'whoops! invalid credential has been used!','error'=>$exception->getMessage()], 401);
}
// ########## Fetch user id from user table
// ########## Match it in user->role table
// ########## Then use value and return role table name
$contacts_id = DB::table('users')->select('id')->where([
['email', '=', $credentials['email']]
])->value('id');

$role = DB::table('user_role')->select('role_id')->where([
['user_id', '=', $contacts_id]
])->value('role_id');

$role_name = DB::table('roles')->select('name')->where([
['id', '=', $role]
])->value('name');

// >>>>>>>>>>>>>>||||||| Check Role for Login ||||||||<<<<<<<<<<<<<<<<<<<

if($role_name == 'Admin' || $role_name == 'User'){
$user = Auth::user();
$token = $user->createToken('authToken')->accessToken;

// $user_id=auth('api')->user()->id;
// $id=$user_id->id;
$id=$user->id;
$role=User::find($id)->roles;

return response()->json(['status'=>true, 'message'=>'Authentication Successful','User_role_id'=>$role,'result'=>$user, 'token'=>$token],200);
}else{

return response()->json(['status'=>false, 'message'=>'Woops UnAuthenticated!!!!'],500);
}

}catch (Exception $exception){
return response()->json(['status'=>false, 'result'=>null, 'message'=>'whoops! exception has occurred', 'error'=>$exception->getMessage()],500);
}
}


public function logout (Request $request) {

$token = $request->user()->token();
$token->revoke();

$response = 'You have been succesfully logged out!';
return response($response, 200);

}

public function loginSys(){

}
}
45 changes: 45 additions & 0 deletions app/Http/Controllers/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\User;
use App\Role;

class AppController extends Controller
{
public function __construct() {
$this->middleware('auth:api');
}

public function postAdminAssignRoles($value,$id)
{
############ check box condition #######################

// $user->roles()->attach(Role::where('name', 'User')->first());

if($value == true){

$user = User::where([['id','=', $id]])->first();
$user->roles()->attach(Role::where('name', 'User')->first());

$accessToken = $user ->createToken('authToken')->accessToken;
return response(['Role Added to user' => $user,'access_token' => $accessToken]);

}else{
$user = User::where([['id','=', $id]])->first();
$user->roles()->detach();
return response(['Role detached from user' => $user]);
}

/* if ($request['role_user']) {
$user->roles()->attach(Role::where('name', 'User')->first());
}
return redirect()->back(); */
}

public function adminPage(){
return response(['Admin page']);
}
}
Loading