Initial commit
This commit is contained in:
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');
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
81
app/Http/Controllers/DashboardController.php
Normal file
81
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
|
||||
public function index(){
|
||||
// dd('public insanity');
|
||||
return view('dashboard.index');
|
||||
}
|
||||
|
||||
public function getDashboardStats()
|
||||
{
|
||||
|
||||
$stats = DB::table('unified_subscribers')
|
||||
->select('service_id', DB::raw('count(*) as total'), DB::raw('SUM(status = "active") as active_count'))
|
||||
->groupBy('service_id')
|
||||
->get();
|
||||
return response()->json($stats);
|
||||
}
|
||||
public function getStats()
|
||||
{
|
||||
// Query the unified warehouse table, grouping by the service configuration
|
||||
$stats = DB::table('subscription_services as s')
|
||||
->leftJoin('unified_subscribers as u', 's.id', '=', 'u.service_id')
|
||||
->select(
|
||||
's.id',
|
||||
's.name',
|
||||
DB::raw('COUNT(u.id) as total_subscribers'),
|
||||
// Use CASE WHEN for strict SQL compatibility
|
||||
DB::raw('SUM(CASE WHEN u.status = "active" THEN 1 ELSE 0 END) as active_subscribers')
|
||||
)
|
||||
->groupBy('s.id', 's.name')
|
||||
->get();
|
||||
|
||||
// Calculate a quick summary for the top-level overview
|
||||
$grandTotal = $stats->sum('total_subscribers');
|
||||
$grandActive = $stats->sum('active_subscribers');
|
||||
|
||||
return response()->json([
|
||||
'summary' => [
|
||||
'total' => $grandTotal,
|
||||
'active' => $grandActive,
|
||||
'inactive' => $grandTotal - $grandActive
|
||||
],
|
||||
'services' => $stats
|
||||
]);
|
||||
}
|
||||
// app/Http/Controllers/DashboardController.php
|
||||
// app/Http/Controllers/DashboardController.php
|
||||
public function details(Request $request, $id)
|
||||
{
|
||||
$service = DB::table('subscription_services')->where('id', $id)->first();
|
||||
|
||||
if (!$service) {
|
||||
abort(404, 'Service not found.');
|
||||
}
|
||||
|
||||
$search = $request->input('search');
|
||||
|
||||
$subscribers = DB::table('unified_subscribers')
|
||||
->where('service_id', $id)
|
||||
->when($search, function($query, $search) {
|
||||
$query->where(function($q) use ($search) {
|
||||
$q->where('phone_number', 'like', "%{$search}%")
|
||||
->orWhere('content_name', 'like', "%{$search}%")
|
||||
->orWhere('status', 'like', "%{$search}%")
|
||||
->orWhere('join_date', 'like', "%{$search}%");
|
||||
});
|
||||
})
|
||||
->orderBy('updated_at', 'desc')
|
||||
->paginate(15);
|
||||
|
||||
return view('dashboard.details', compact('service', 'subscribers'));
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
93
app/Http/Controllers/SubscriptionServiceController.php
Normal file
93
app/Http/Controllers/SubscriptionServiceController.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Exception;
|
||||
|
||||
|
||||
class SubscriptionServiceController extends Controller
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return view('services.create');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
// 1. Validate the incoming data
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'schema_type' => 'required|string|in:type_a,type_b', // Restrict to known schema mappers
|
||||
'db_host' => 'required|string|max:255',
|
||||
'db_port' => 'required|integer|min:1|max:65535',
|
||||
'db_name' => 'required|string|max:255',
|
||||
'db_user' => 'required|string|max:255',
|
||||
'db_password' => 'required|string', // Plain text from form
|
||||
]);
|
||||
|
||||
// 2. Insert into the database with encryption
|
||||
DB::table('subscription_services')->insert([
|
||||
'name' => $validated['name'],
|
||||
'schema_type' => $validated['schema_type'],
|
||||
'db_host' => $validated['db_host'],
|
||||
'db_port' => $validated['db_port'],
|
||||
'db_name' => $validated['db_name'],
|
||||
'db_user' => $validated['db_user'],
|
||||
'db_password' => Crypt::encryptString($validated['db_password']), // Secure encryption
|
||||
'last_synced_at' => null, // Will be populated on first ETL run
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
// 3. Redirect back with a success message
|
||||
return redirect()
|
||||
->route('services.create')
|
||||
->with('success', 'Subscription service added successfully.');
|
||||
}
|
||||
|
||||
public function testConnection(Request $request)
|
||||
{
|
||||
// Validate the incoming AJAX payload
|
||||
$request->validate([
|
||||
'db_host' => 'required|string',
|
||||
'db_port' => 'required|integer',
|
||||
'db_name' => 'required|string',
|
||||
'db_user' => 'required|string',
|
||||
'db_password' => 'required|string',
|
||||
]);
|
||||
|
||||
try {
|
||||
// 1. Set a temporary dynamic configuration
|
||||
Config::set('database.connections.test_dynamic', [
|
||||
'driver' => 'mysql',
|
||||
'host' => $request->db_host,
|
||||
'port' => $request->db_port,
|
||||
'database' => $request->db_name,
|
||||
'username' => $request->db_user,
|
||||
'password' => $request->db_password,
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
]);
|
||||
|
||||
DB::purge('test_dynamic');
|
||||
|
||||
// 2. Attempt to resolve the PDO instance to verify the connection
|
||||
DB::connection('test_dynamic')->getPdo();
|
||||
|
||||
// 3. Return success if no exception was thrown
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Connection established successfully.'
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Connection failed: ' . $e->getMessage()
|
||||
], 400); // 400 Bad Request triggers the AJAX error block
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user