Initial commit
This commit is contained in:
99
app/Http/Controllers/AdminController.php
Normal file
99
app/Http/Controllers/AdminController.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Utilities\ApiCalls;
|
||||
use Session;
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$user_id = \Auth::user()->id;
|
||||
// dd($user_id);
|
||||
$clients_url = "clients?page=0&size=20&sort=createdAt,desc";
|
||||
$result = ApiCalls::CurlGet($clients_url);
|
||||
$result_arr = json_decode($result);
|
||||
// dump($result_arr);
|
||||
$data = [
|
||||
'page_title' => 'Client List',
|
||||
'clients' => $result_arr
|
||||
];
|
||||
return view('clients.index', $data);
|
||||
}
|
||||
public function create() {
|
||||
// Show form to create a new post
|
||||
return view('clients.create');
|
||||
}
|
||||
|
||||
public function store(Request $request) {
|
||||
// Save a new post
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email'=> 'required',
|
||||
'phoneNumber' => 'required',
|
||||
'country' => 'required',
|
||||
// 'status' => 'required',
|
||||
]);
|
||||
$client_arr = $request->except('_token');
|
||||
$create_client_url = "clients";
|
||||
$result = ApiCalls::CurlPost(json_encode($client_arr), $create_client_url);
|
||||
if ($result) {
|
||||
Session::flash('success_message', 'client created successfully!');
|
||||
}
|
||||
else{
|
||||
Session::flash('error_message', 'client could not be created !');
|
||||
}
|
||||
return redirect(url('admin/clients'));
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
// Show a specific post
|
||||
$user_id = \Auth::user()->id;
|
||||
$client_url = "clients/1";
|
||||
$result = ApiCalls::CurlGet($clients_url);
|
||||
$result_arr = json_decode($result);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'clients Details',
|
||||
'client' => $result_arr
|
||||
];
|
||||
// dump($data);
|
||||
return view('clients.show', $data);
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
// Show form to edit a post
|
||||
$user_id = \Auth::user()->id;
|
||||
$result = [];
|
||||
$data = [
|
||||
'page_title' => 'clients Update',
|
||||
'client' => $result
|
||||
];
|
||||
return view('clients.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
// Update a specific post
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email'=> 'required',
|
||||
'phone' => 'required',
|
||||
'country' => 'country',
|
||||
'status' => 'required',
|
||||
]);
|
||||
|
||||
$client = [];
|
||||
|
||||
$client->name = $request->name;
|
||||
$client->description = $request->description;
|
||||
$client->dependancy = $request->dependancy;
|
||||
$client->status = $request->status;
|
||||
$result = $client->save();
|
||||
Session::flash('success_message', 'client details updated successfully!');
|
||||
return redirect(url('clients'));
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
// Delete a specific post
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
||||
40
app/Http/Controllers/Auth/LoginController.php
Normal file
40
app/Http/Controllers/Auth/LoginController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('auth')->only('logout');
|
||||
}
|
||||
}
|
||||
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
}
|
||||
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
||||
58
app/Http/Controllers/ClientsLoginController.php
Normal file
58
app/Http/Controllers/ClientsLoginController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use App\Utilities\ApiCalls;
|
||||
use Session;
|
||||
class ClientsLoginController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'User Login'
|
||||
];
|
||||
return view('client-auth.login-test', $data);
|
||||
|
||||
}
|
||||
|
||||
public function handleLogin(Request $request){
|
||||
|
||||
$this->validate($request, ['email' => 'required', 'password' => 'required']);
|
||||
$logged_in = '';
|
||||
|
||||
$client_url = "clients/1";
|
||||
$result = ApiCalls::CurlGet($client_url);
|
||||
$result_arr = json_decode($result, true);
|
||||
|
||||
// dd($result_arr);
|
||||
|
||||
$logged_in = $result_arr;
|
||||
|
||||
$request->session()->regenerate(true);
|
||||
$request->session()->put('current_user.user_id', $logged_in['id']);
|
||||
$request->session()->put('current_user.name', $logged_in['name']);
|
||||
$request->session()->put('current_user.email', $logged_in['email']);
|
||||
$request->session()->put('current_user.phoneNumber', $logged_in['phoneNumber']);
|
||||
$request->session()->put('current_user.status', $logged_in['status']);
|
||||
$request->session()->put('current_user.createdAt', $logged_in['createdAt']);
|
||||
$request->session()->put('current_user.updatedAt', $logged_in['updatedAt']);
|
||||
// dd('after session');
|
||||
|
||||
\Log::info($logged_in['name']. ' Successfully logged in at : ' . date('Y-m-d H:i:s'));
|
||||
return redirect(url('/'));
|
||||
}
|
||||
public function handle_logout(Request $request) {
|
||||
$user_id = session('current_user.id');
|
||||
$name = session('current_user.name');
|
||||
|
||||
|
||||
$request->session()->forget('current_user');
|
||||
$request->session()->flush();
|
||||
$request->session()->regenerate(true);
|
||||
|
||||
\Log::info($name . ' Successfully logged out at : ' . date('Y-m-d H:i:s'));
|
||||
Session::flash('success_message', 'You have successfully logged out!');
|
||||
return redirect("/");
|
||||
}
|
||||
}
|
||||
37
app/Http/Controllers/ClientsTrafficController.php
Normal file
37
app/Http/Controllers/ClientsTrafficController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use App\Utilities\ApiCalls;
|
||||
use Session;
|
||||
|
||||
|
||||
class ClientsTrafficController extends Controller
|
||||
{
|
||||
//
|
||||
public function index(){
|
||||
$clients_url = "messages/client/1?page=0&size=20&sort=createdAt,desc";
|
||||
$result = ApiCalls::CurlGet($clients_url);
|
||||
$result_arr = json_decode($result);
|
||||
// dump($result_arr);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Traffic Dashboard',
|
||||
'traffic_arr' => $result_arr
|
||||
];
|
||||
return view('client-traffic.index', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function smsForm(){
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Send SMS',
|
||||
];
|
||||
return view('client-traffic.send-sms', $data);
|
||||
|
||||
}
|
||||
}
|
||||
63
app/Http/Controllers/CommentsController.php
Normal file
63
app/Http/Controllers/CommentsController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Session;
|
||||
use App\Models;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CommentsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$user_id = \Auth::user()->id;
|
||||
$result = Models\Comment::with('projectStatus')
|
||||
->where('assignee_id', $user_id)
|
||||
->orderBy('project_id', 'DESC')
|
||||
->get();
|
||||
$data = [
|
||||
'page_title' => 'Projects Status List',
|
||||
'project_statuses' => $result
|
||||
];
|
||||
return view('comments.index', $data);
|
||||
}
|
||||
public function add_comment($id){
|
||||
$result = Models\ProjectStatus::with('comments', 'project')->where('id', $id)->firstOrFail();
|
||||
// dd($result);
|
||||
$data = [
|
||||
'page_title' => 'Projects Status Comment',
|
||||
'project_arr' => $result
|
||||
];
|
||||
// dump($data);
|
||||
return view('comments.create', $data);
|
||||
}
|
||||
public function store(Request $request) {
|
||||
// Save a new post
|
||||
$this->validate($request, [
|
||||
'description' => 'required',
|
||||
'status' => 'required',
|
||||
'project_id' => 'required',
|
||||
'assignee_id' => 'required'
|
||||
]);
|
||||
$project_status_arr = $request->except('_token');
|
||||
$result = Models\ProjectStatus::create($project_status_arr);
|
||||
Session::flash('success_message', 'Project status added successfully!');
|
||||
|
||||
return redirect(url('project-status'));
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
// Show a specific post
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
// Show form to edit a post
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
// Update a specific post
|
||||
return redirect(url('project-status'));
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
// Delete a specific post
|
||||
}
|
||||
}
|
||||
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
||||
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
69
app/Http/Controllers/ProjectStatusesController.php
Normal file
69
app/Http/Controllers/ProjectStatusesController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Session;
|
||||
use App\Models;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProjectStatusesController extends Controller
|
||||
{
|
||||
//load up project status
|
||||
public function index(){
|
||||
$user_id = \Auth::user()->id;
|
||||
// dd($user_id);
|
||||
$result = Models\ProjectStatus::with('project')
|
||||
->where('assignee_id', $user_id)
|
||||
->orderBy('project_id', 'DESC')
|
||||
->get();
|
||||
$data = [
|
||||
'page_title' => 'Projects Status List',
|
||||
'project_statuses' => $result
|
||||
];
|
||||
return view('project_status.index', $data);
|
||||
}
|
||||
public function add_status($id){
|
||||
$result = Models\Project::with('statusInfo')->where('id', $id)->firstOrFail();
|
||||
$data = [
|
||||
'page_title' => 'Projects Status Update',
|
||||
'project' => $result
|
||||
];
|
||||
// dd($data);
|
||||
return view('project_status.add_status', $data);
|
||||
}
|
||||
public function create() {
|
||||
|
||||
return view('project_status.create');
|
||||
}
|
||||
|
||||
public function store(Request $request) {
|
||||
// Save a new post
|
||||
$this->validate($request, [
|
||||
'description' => 'required',
|
||||
'status' => 'required',
|
||||
'project_id' => 'required',
|
||||
'assignee_id' => 'required'
|
||||
]);
|
||||
$project_status_arr = $request->except('_token');
|
||||
$result = Models\ProjectStatus::create($project_status_arr);
|
||||
Session::flash('success_message', 'Project status added successfully!');
|
||||
|
||||
return redirect(url('projects'));
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
// Show a specific post
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
// Show form to edit a post
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
// Update a specific post
|
||||
return redirect(url('project-status'));
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
// Delete a specific post
|
||||
}
|
||||
}
|
||||
86
app/Http/Controllers/ProjectsController.php
Normal file
86
app/Http/Controllers/ProjectsController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Session;
|
||||
use App\Models;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProjectsController extends Controller
|
||||
{
|
||||
|
||||
public function index(){
|
||||
$user_id = \Auth::user()->id;
|
||||
// dd($user_id);
|
||||
$result = Models\Project::where('user_id', $user_id)->get();
|
||||
$data = [
|
||||
'page_title' => 'Projects List',
|
||||
'projects' => $result
|
||||
];
|
||||
return view('projects.index', $data);
|
||||
}
|
||||
public function create() {
|
||||
// Show form to create a new post
|
||||
return view('projects.create');
|
||||
}
|
||||
|
||||
public function store(Request $request) {
|
||||
// Save a new post
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'description'=> 'required',
|
||||
'dependancy' => 'sometimes',
|
||||
'status' => 'required',
|
||||
]);
|
||||
$project_arr = $request->except('_token');
|
||||
$result = Models\Project::create($project_arr);
|
||||
Session::flash('success_message', 'Project created successfully!');
|
||||
return redirect(url('projects'));
|
||||
}
|
||||
|
||||
public function show($id) {
|
||||
// Show a specific post
|
||||
$user_id = \Auth::user()->id;
|
||||
$result = Models\Project::with('statusInfo')->where('id', $id)->firstOrFail();
|
||||
$data = [
|
||||
'page_title' => 'Projects Details',
|
||||
'project' => $result
|
||||
];
|
||||
// dump($data);
|
||||
return view('projects.show', $data);
|
||||
}
|
||||
|
||||
public function edit($id) {
|
||||
// Show form to edit a post
|
||||
$user_id = \Auth::user()->id;
|
||||
$result = Models\Project::with('statusInfo')->where('id', $id)->firstOrFail();
|
||||
$data = [
|
||||
'page_title' => 'Projects Update',
|
||||
'project' => $result
|
||||
];
|
||||
return view('projects.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id) {
|
||||
// Update a specific post
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'description'=> 'required',
|
||||
'dependancy' => 'sometimes',
|
||||
'status' => 'required',
|
||||
]);
|
||||
|
||||
$project = Models\Project::findOrFail($id);
|
||||
|
||||
$project->name = $request->name;
|
||||
$project->description = $request->description;
|
||||
$project->dependancy = $request->dependancy;
|
||||
$project->status = $request->status;
|
||||
$result = $project->save();
|
||||
Session::flash('success_message', 'Project details updated successfully!');
|
||||
return redirect(url('projects'));
|
||||
}
|
||||
|
||||
public function destroy($id) {
|
||||
// Delete a specific post
|
||||
}
|
||||
}
|
||||
25
app/Http/Middleware/CheckClientSession.php
Normal file
25
app/Http/Middleware/CheckClientSession.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckClientSession
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if(!$request->session()->has('current_user')){
|
||||
// dd('in the Middleware');
|
||||
return redirect(url('client-login'))->withErrors("Enter Credentials to gain access");
|
||||
}
|
||||
// dd('before next in the Middleware');
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
23
app/Models/Comment.php
Normal file
23
app/Models/Comment.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
public function userInfo(): HasOne
|
||||
{
|
||||
return $this->hasOne(User::class);
|
||||
}
|
||||
public function projectStatus(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ProjectStatus::class);
|
||||
}
|
||||
}
|
||||
31
app/Models/Project.php
Normal file
31
app/Models/Project.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
// public function userInfo()
|
||||
// {
|
||||
// return $this->hasMany('App\Models\User', 'org_id', 'id');
|
||||
// }
|
||||
// public function phone(): HasOne
|
||||
// {
|
||||
// return $this->hasOne(Phone::class);
|
||||
// }
|
||||
public function userInfo(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
public function statusInfo(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProjectStatus::class);
|
||||
}
|
||||
}
|
||||
23
app/Models/ProjectStatus.php
Normal file
23
app/Models/ProjectStatus.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ProjectStatus extends Model
|
||||
{
|
||||
protected $guarded = [
|
||||
'id'
|
||||
];
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class);
|
||||
}
|
||||
public function comments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
}
|
||||
48
app/Models/User.php
Normal file
48
app/Models/User.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Providers/AppServiceProvider.php
Normal file
24
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
58
app/Utilities/ApiCalls.php
Normal file
58
app/Utilities/ApiCalls.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
class ApiCalls
|
||||
{
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
|
||||
public static function CurlGet($url){
|
||||
$get_url = env('APIBASEURL') . $url;
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $get_url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
|
||||
}
|
||||
public static function CurlPost($data, $url){
|
||||
$post_url = env('APIBASEURL') . $url;
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => $post_url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public static function generatePassword($length = 10) {
|
||||
return bin2hex(random_bytes($length / 2));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user