first
This commit is contained in:
96
app/Helpers/Helper.php
Normal file
96
app/Helpers/Helper.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
use Carbon\Carbon;
|
||||
use Modules\CCMS\Models\Setting;
|
||||
|
||||
if (!function_exists('setting')) {
|
||||
function setting($key = null)
|
||||
{
|
||||
$setting = Cache::has('setting') ? Cache::get('setting') : Cache::rememberForever('setting', function () {
|
||||
return Setting::get()->mapWithKeys(function (Setting $setting) {
|
||||
return [$setting->key => $setting->value];
|
||||
})->toArray();
|
||||
});
|
||||
|
||||
return array_key_exists($key, $setting) ? $setting[$key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('uploadImage')) {
|
||||
function uploadImage($file, $path = 'uploads')
|
||||
{
|
||||
$fileName = uniqid() . '.' . $file->getClientOriginalExtension();
|
||||
$filePath = Storage::disk('public')->putFileAs($path, $file, $fileName);
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
|
||||
function getPageTemplateOptions()
|
||||
{
|
||||
$client = config('app.client');
|
||||
$pageTemplateOptions = collect(File::files(resource_path("views/client/{$client}/pages")))
|
||||
->mapWithKeys(function ($file) {
|
||||
$template = Str::replace('.blade.php', '', $file->getFilename());
|
||||
return [
|
||||
$template => $template,
|
||||
];
|
||||
});
|
||||
|
||||
return $pageTemplateOptions->all();
|
||||
}
|
||||
|
||||
if (!function_exists('getFormatted')) {
|
||||
function getFormatted($dateTime = null, $date = null, $time = null, $format = null)
|
||||
{
|
||||
$data = null;
|
||||
|
||||
switch (true) {
|
||||
case !is_null($dateTime):
|
||||
$data = $dateTime;
|
||||
$format ??= 'd M, Y h:i A';
|
||||
break;
|
||||
|
||||
case !is_null($date) && !is_null($time):
|
||||
|
||||
$data = "{$date} {$time}";
|
||||
$format ??= 'd M, Y h:i A';
|
||||
break;
|
||||
|
||||
case !is_null($date):
|
||||
|
||||
$data = $date;
|
||||
$format ??= 'd M, Y';
|
||||
break;
|
||||
|
||||
case !is_null($time):
|
||||
$data = $time;
|
||||
$format ??= 'h:i A';
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$formatted = Carbon::parse($data)->format($format);
|
||||
return $formatted;
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getThemeColor()
|
||||
{
|
||||
static $themeColor;
|
||||
|
||||
if ($themeColor === null) {
|
||||
$themeColor = setting('color') ?? '#F3F3F9';
|
||||
}
|
||||
|
||||
return $themeColor;
|
||||
}
|
||||
|
||||
function isEmptyArray($array = [])
|
||||
{
|
||||
return is_array($array) && array_filter($array) === [];
|
||||
}
|
||||
}
|
||||
235
app/Helpers/QueryHelper.php
Normal file
235
app/Helpers/QueryHelper.php
Normal file
@@ -0,0 +1,235 @@
|
||||
|
||||
<?php
|
||||
|
||||
use Modules\CCMS\Models\Blog;
|
||||
use Modules\CCMS\Models\Category;
|
||||
use Modules\CCMS\Models\Counter;
|
||||
use Modules\CCMS\Models\Country;
|
||||
use Modules\CCMS\Models\Faq;
|
||||
use Modules\CCMS\Models\FaqCategory;
|
||||
use Modules\CCMS\Models\GalleryCategory;
|
||||
use Modules\CCMS\Models\Institution;
|
||||
use Modules\CCMS\Models\Page;
|
||||
use Modules\CCMS\Models\Service;
|
||||
use Modules\CCMS\Models\Slider;
|
||||
use Modules\CCMS\Models\Team;
|
||||
use Modules\CCMS\Models\Test;
|
||||
use Modules\CCMS\Models\Testimonial;
|
||||
use Modules\Menu\Models\Menu;
|
||||
function getSliders(?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
return Slider::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getBlogCategories(?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
return Category::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getFAQs(?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
return Faq::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getTeams(?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
return Team::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getTestimonials(?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
return Testimonial::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getBlogs(?int $limit = null, ?string $order = 'desc', bool $paginate = false)
|
||||
{
|
||||
$query = Blog::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order);
|
||||
|
||||
if ($limit && $paginate) {
|
||||
return $query->paginate($limit);
|
||||
} elseif ($limit && !$paginate) {
|
||||
return $query->limit($limit)->get();
|
||||
} else {
|
||||
return $query->get();
|
||||
}
|
||||
}
|
||||
|
||||
function getBlogBySlug(?string $slug)
|
||||
{
|
||||
return Blog::query()
|
||||
->where('status', 1)
|
||||
->where('slug', $slug)
|
||||
->first();
|
||||
}
|
||||
|
||||
function getCounters($limit = null, $order = 'desc')
|
||||
{
|
||||
return Counter::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getServices($limit = null, $order = 'desc')
|
||||
{
|
||||
return Service::query()
|
||||
->where('status', 1)
|
||||
->where('parent_id', null)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getInstitutions($limit = null, $order = 'desc')
|
||||
{
|
||||
return Institution::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getClasses($limit = null, $order = 'desc')
|
||||
{
|
||||
return Test::query()
|
||||
->where('status', 1)
|
||||
->where('parent_id', null)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getDestinations($limit = null, $order = 'desc')
|
||||
{
|
||||
return Country::query()
|
||||
->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
function getGalleriesByCategory(?int $limit = null, ?string $order = 'desc', ?string $category = null)
|
||||
{
|
||||
return GalleryCategory::query()
|
||||
->where('status', 1)
|
||||
->where('slug', $category)
|
||||
->with('galleries', function ($query) use ($limit, $order) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
});
|
||||
})
|
||||
->first();
|
||||
}
|
||||
|
||||
function getInstitutionsByCountry(?int $limit = null, ?string $order = 'desc', ?string $country = null)
|
||||
{
|
||||
return Country::query()
|
||||
->where('status', 1)
|
||||
->where('slug', $country)
|
||||
->with('institutions', function ($query) use ($limit, $order) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
});
|
||||
})
|
||||
->first();
|
||||
}
|
||||
|
||||
function getFAQsByCategory(?int $limit = null, ?string $order = 'desc', ?string $category = null)
|
||||
{
|
||||
return FaqCategory::query()
|
||||
->where('status', 1)
|
||||
->where('slug', $category)
|
||||
->with('faqs', function ($query) use ($limit, $order) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
});
|
||||
})
|
||||
->first();
|
||||
}
|
||||
|
||||
function getPageWithChildrenBySlug(?string $parent, ?string $slug, ?int $limit = null, ?string $order = 'desc')
|
||||
{
|
||||
$page = Page::where([
|
||||
'status' => 1,
|
||||
'type' => 'page',
|
||||
'slug' => $slug,
|
||||
])
|
||||
->when($parent, function ($query) use ($parent) {
|
||||
$query->where('parent', $parent);
|
||||
})
|
||||
->with(['children' => function ($query) use ($limit, $order) {
|
||||
$query->orderBy('order', $order)
|
||||
->when($limit, function ($query) use ($limit) {
|
||||
$query->limit($limit);
|
||||
});
|
||||
}])
|
||||
->first();
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
function getAllHeaderMenusWithChildren()
|
||||
{
|
||||
$headerMenuItems = Menu::where(['menu_location_id' => 1, 'parent_id' => null, 'status' => 1])->with('children', function ($query) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order', 'asc');
|
||||
})->orderBy('order', 'asc')->get();
|
||||
return $headerMenuItems;
|
||||
}
|
||||
|
||||
function getAllFooterMenusWithChildren()
|
||||
{
|
||||
$footerMenuItems = Menu::where(['menu_location_id' => 2, 'parent_id' => null, 'status' => 1])->with('children', function ($query) {
|
||||
$query->orderBy('order', 'asc');
|
||||
})->orderBy('order', 'asc')->get();
|
||||
return $footerMenuItems;
|
||||
}
|
||||
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the login view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming authentication request.
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ConfirmablePasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirm password view.
|
||||
*/
|
||||
public function show(): View
|
||||
{
|
||||
return view('auth.confirm-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (! Auth::guard('web')->validate([
|
||||
'email' => $request->user()->email,
|
||||
'password' => $request->password,
|
||||
])) {
|
||||
throw ValidationException::withMessages([
|
||||
'password' => __('auth.password'),
|
||||
]);
|
||||
}
|
||||
|
||||
$request->session()->put('auth.password_confirmed_at', time());
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EmailVerificationNotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send a new email verification notification.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false));
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EmailVerificationPromptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the email verification prompt.
|
||||
*/
|
||||
public function __invoke(Request $request): RedirectResponse|View
|
||||
{
|
||||
return $request->user()->hasVerifiedEmail()
|
||||
? redirect()->intended(route('dashboard', absolute: false))
|
||||
: view('auth.verify-email');
|
||||
}
|
||||
}
|
||||
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class NewPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset view.
|
||||
*/
|
||||
public function create(Request $request): View
|
||||
{
|
||||
return view('auth.reset-password', ['request' => $request]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming new password request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'token' => ['required'],
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user) use ($request) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($request->password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
);
|
||||
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
return $status == Password::PASSWORD_RESET
|
||||
? redirect()->route('login')->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
||||
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validateWithBag('updatePassword', [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
|
||||
return back()->with('status', 'password-updated');
|
||||
}
|
||||
}
|
||||
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PasswordResetLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset link request view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming password reset link request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
]);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
return $status == Password::RESET_LINK_SENT
|
||||
? back()->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
||||
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RegisteredUserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the registration view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming registration request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
event(new Registered($user));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect(route('dashboard', absolute: false));
|
||||
}
|
||||
}
|
||||
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\Verified;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class VerifyEmailController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mark the authenticated user's email address as verified.
|
||||
*/
|
||||
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
|
||||
if ($request->user()->markEmailAsVerified()) {
|
||||
event(new Verified($request->user()));
|
||||
}
|
||||
|
||||
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||
}
|
||||
}
|
||||
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
46
app/Http/Controllers/DashboardController.php
Normal file
46
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Modules\CCMS\Models\Blog;
|
||||
use Modules\CCMS\Models\Enquiry;
|
||||
use Modules\CCMS\Models\Partner;
|
||||
use Modules\CCMS\Models\Service;
|
||||
use Modules\CCMS\Models\Team;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function dashboard()
|
||||
{
|
||||
return view('dashboard',[
|
||||
'usersCount' => User::count(),
|
||||
'blogsCount' => Blog::where('status', 1)->count(),
|
||||
'teamsCount' => Team::where('status', 1)->count(),
|
||||
'servicesCount' => Service::where('status', 1)->count(),
|
||||
'partnersCount' => Partner::where('status', 1)->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getEnquiries()
|
||||
{
|
||||
// if (request()->ajax()) {
|
||||
$model = Enquiry::query()->where('is_read', 0)->latest();
|
||||
return DataTables::eloquent($model)
|
||||
->addIndexColumn()
|
||||
->editColumn('class', function (Enquiry $enquiry){
|
||||
return $enquiry->class ?? '-';
|
||||
})
|
||||
->editColumn('subject', function (Enquiry $enquiry){
|
||||
return $enquiry->subject ?? '-';
|
||||
})
|
||||
->editColumn('message', function (Enquiry $enquiry){
|
||||
return $enquiry->message ?? '-';
|
||||
})
|
||||
->addColumn('action', 'ccms::enquiry.datatable.action')
|
||||
->rawColumns(['action'])
|
||||
->toJson();
|
||||
// }
|
||||
}
|
||||
}
|
||||
60
app/Http/Controllers/ProfileController.php
Normal file
60
app/Http/Controllers/ProfileController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileUpdateRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the user's profile form.
|
||||
*/
|
||||
public function edit(Request $request): View
|
||||
{
|
||||
return view('profile.edit', [
|
||||
'user' => $request->user(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user's profile information.
|
||||
*/
|
||||
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$request->user()->fill($request->validated());
|
||||
|
||||
if ($request->user()->isDirty('email')) {
|
||||
$request->user()->email_verified_at = null;
|
||||
}
|
||||
|
||||
$request->user()->save();
|
||||
|
||||
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the user's account.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validateWithBag('userDeletion', [
|
||||
'password' => ['required', 'current_password'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
Auth::logout();
|
||||
|
||||
$user->delete();
|
||||
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
273
app/Http/Controllers/WebsiteController.php
Normal file
273
app/Http/Controllers/WebsiteController.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Rules\Recaptcha;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Modules\CCMS\Models\Blog;
|
||||
use Modules\CCMS\Models\Country;
|
||||
use Modules\CCMS\Models\Enquiry;
|
||||
use Modules\CCMS\Models\Institution;
|
||||
use Modules\CCMS\Models\Page;
|
||||
use Modules\CCMS\Models\Service;
|
||||
use Modules\CCMS\Models\Slider;
|
||||
use Modules\CCMS\Models\Test;
|
||||
use Modules\CourseFinder\Models\Coop;
|
||||
use Modules\CourseFinder\Models\Program;
|
||||
use Modules\CourseFinder\Models\ProgramLevel;
|
||||
use Modules\CourseFinder\Services\ProgramService;
|
||||
|
||||
class WebsiteController extends Controller
|
||||
{
|
||||
private $path;
|
||||
protected $programService;
|
||||
public function __construct(ProgramService $programService)
|
||||
{
|
||||
$this->programService = $programService;
|
||||
$headerMenus = getAllHeaderMenusWithChildren();
|
||||
$footerMenus = getAllFooterMenusWithChildren();
|
||||
$this->path = config('app.client');
|
||||
|
||||
view()->share([
|
||||
'headerMenus' => $headerMenus,
|
||||
'footerMenus' => $footerMenus,
|
||||
]);
|
||||
}
|
||||
|
||||
public function home()
|
||||
{
|
||||
$data['firstImage'] = Slider::where('status', 1)->orderBy('order')->first();
|
||||
$data['sliders'] = getSliders(limit: null, order: 'asc');
|
||||
$data['counters'] = getCounters(limit: null, order: 'asc');
|
||||
$data['successGalleries'] = getGalleriesByCategory(limit: 3, order: 'asc', category: 'voice-of-success');
|
||||
$data['destinations'] = getDestinations(limit: null, order: 'asc');
|
||||
$data['services'] = getServices(limit: null, order: 'asc');
|
||||
$data['classes'] = getClasses(limit: null, order: 'asc');
|
||||
$data['institutions'] = getInstitutions(limit: null, order: 'asc');
|
||||
$data['faqs'] = getFAQs(limit: null, order: 'desc');
|
||||
$data['testimonials'] = getTestimonials(limit: null, order: 'desc');
|
||||
$data['blogs'] = getBlogs(limit: 4, order: 'desc');
|
||||
$data['achievementGalleries'] = getGalleriesByCategory(limit: null, order: 'asc', category: 'achievement');
|
||||
$data['visaGalleries'] = getGalleriesByCategory(limit: null, order: 'asc', category: 'visa-success');
|
||||
$data['dishes'] = getGalleriesByCategory(limit: null, order: 'asc', category: 'dishes');
|
||||
$page = $data['page'] = getPageWithChildrenBySlug(parent: null, slug: '/', limit: null, order: 'asc');
|
||||
|
||||
if (!$page) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$path = "client.$this->path.pages.$page->template";
|
||||
|
||||
if (!View::exists($path)) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
return view($path, $data);
|
||||
}
|
||||
|
||||
public function blogSingle($alias)
|
||||
{
|
||||
$blog = $data["page"] = Blog::where('status', 1)
|
||||
->where('slug', $alias)->first();
|
||||
|
||||
if (!$blog) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$data['categories'] = getBlogCategories(limit: null, order: 'desc');
|
||||
|
||||
$data['recentBlogs'] = Blog::where('status', 1)
|
||||
->where('id', '!=', $blog->id)
|
||||
->inRandomOrder()
|
||||
->orderBy('created_at', 'desc')
|
||||
->take(5)->get();
|
||||
|
||||
$blog->increment('views');
|
||||
|
||||
return view("client.$this->path.pages.blog-single-template", $data);
|
||||
}
|
||||
|
||||
public function serviceSingle($alias)
|
||||
{
|
||||
$service = $data["page"] = Service::where('status', 1)
|
||||
->where('slug', $alias)
|
||||
->with('children', function ($query) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order');
|
||||
})
|
||||
->first();
|
||||
|
||||
if (!$service) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$data['allServices'] = Service::where('status', 1)
|
||||
->where('parent_id', null)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
$data['serviceFAQs'] = getFAQsByCategory(limit: null, order: 'desc', category: $service->slug);
|
||||
|
||||
|
||||
|
||||
if ($service->slug == 'test-preparation') {
|
||||
$data['tests'] = Test::where(['status' => 1, 'parent_id' => null])->orderBy('order')->with('children', function ($query) {
|
||||
$query->where('status', 1)
|
||||
->orderBy('order');
|
||||
})->get();
|
||||
|
||||
$data['testimonials'] = getTestimonials(limit: 5, order: 'desc');
|
||||
return view("client.$this->path.pages.service-single-test-template", $data);
|
||||
}
|
||||
|
||||
return view("client.$this->path.pages.service-single-template", $data);
|
||||
}
|
||||
|
||||
public function countrySingle($alias)
|
||||
{
|
||||
$country = $data["page"] = Country::where('status', 1)
|
||||
->where('slug', $alias)
|
||||
->with('institutions', function ($query) {
|
||||
$query->where('status', 1);
|
||||
})
|
||||
->first();
|
||||
|
||||
if (!$country) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$data['countryFAQs'] = getFAQsByCategory(limit: null, order: 'desc', category: $country->slug);
|
||||
$data['countryInstitutions'] = $country->institutions;
|
||||
|
||||
$data['recentCountries'] = Country::where('status', 1)
|
||||
->where('id', '!=', $country->id)
|
||||
->inRandomOrder()
|
||||
->orderBy('created_at', 'desc')
|
||||
->take(5)->get();
|
||||
|
||||
return view("client.$this->path.pages.country-single-template", $data);
|
||||
}
|
||||
|
||||
public function testSingle($alias)
|
||||
{
|
||||
$test = $data["page"] = Test::where('status', 1)
|
||||
->where('slug', $alias)
|
||||
->first();
|
||||
|
||||
if (!$test) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$data['children'] = Test::where('status', 1)
|
||||
->where('parent_id', $test->id)
|
||||
->get();
|
||||
$data['testFAQs'] = getFAQsByCategory(limit: null, order: 'desc', category: $test->slug);
|
||||
|
||||
$data['allTests'] = Test::where('status', 1)
|
||||
->where('parent_id', null)
|
||||
->select('title', 'slug')
|
||||
->get();
|
||||
|
||||
return view("client.$this->path.pages.test-single-template", $data);
|
||||
}
|
||||
|
||||
public function loadPage(?string $parent = null, ?string $slug = null)
|
||||
{
|
||||
if ($slug === null) {
|
||||
$slug = $parent;
|
||||
$parent = null;
|
||||
}
|
||||
|
||||
$page = getPageWithChildrenBySlug(parent: $parent, slug: $slug, limit: null, order: 'asc');
|
||||
|
||||
if (!$page) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
$path = "client.$this->path.pages.$page->template";
|
||||
|
||||
if (!View::exists($path)) {
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
return view($path, ['page' => $page]);
|
||||
}
|
||||
|
||||
public function fallback()
|
||||
{
|
||||
return view("client.$this->path.errors.404");
|
||||
}
|
||||
|
||||
public function coursefinder(Request $request)
|
||||
{
|
||||
$data['page'] = Page::where(['slug' => 'course-finder', 'status' => 1])->first();
|
||||
$data['title'] = 'Program List';
|
||||
$data['programs'] = $this->programService->findAll($request);
|
||||
$data['countryOptions'] = Country::where('status', 1)->pluck('title', 'id');
|
||||
|
||||
$data['institutionOptions'] = Institution::query()
|
||||
->when($request->filled('country_id'), function ($query) use ($request) {
|
||||
$query->where('country_id', $request->country_id);
|
||||
})
|
||||
->pluck('title', 'id');
|
||||
|
||||
$data['programLevelOptions'] = ProgramLevel::where('status', 1)->pluck('title', 'id');
|
||||
$data['intakeOptions'] = Program::INTAKE;
|
||||
$data['coopOptions'] = Coop::where('status', 1)->pluck('title', 'id');
|
||||
$data['testOptions'] = Test::where('status', 1)->where('parent_id', null)->pluck('title', 'id');
|
||||
$data['statusOptions'] = config('constants.page_status_options');
|
||||
|
||||
return view("client.$this->path.pages.coursefinder-template", $data);
|
||||
}
|
||||
|
||||
|
||||
public function storeEnquiries(Request $request)
|
||||
{
|
||||
$request->merge([
|
||||
'type' => $request->input('type', 'enquiries')
|
||||
]);
|
||||
try {
|
||||
$rules = [
|
||||
'type' => 'required|in:enquiries,booking',
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
'mobile' => 'nullable',
|
||||
'subject' => 'nullable',
|
||||
'class' => 'nullable',
|
||||
'message' => 'nullable|max:250',
|
||||
];
|
||||
|
||||
if (setting('enable_reCaptcha') == 1) {
|
||||
$rules['g-recaptcha-response'] = ['required', new Recaptcha];
|
||||
}
|
||||
|
||||
$messages = [
|
||||
'email.email' => 'Must be a valid email address.',
|
||||
'mobile.numeric' => 'Must be a valid phone number.',
|
||||
'mobile.digits' => 'Must be a valid phone number.',
|
||||
'g-recaptcha-response.required' => 'Please complete reCAPTCHA validation.',
|
||||
'g-recaptcha-response' => 'Invalid reCAPTCHA.',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules, $messages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
// dd($request->all());
|
||||
return response()->json(['errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
$validatedData = $validator->validated();
|
||||
// $validatedData['type'] = 'enquiries'; // Set the type
|
||||
|
||||
Enquiry::create($validatedData);
|
||||
|
||||
// Enquiry::create($validator->validated());
|
||||
|
||||
return response()->json(['status' => 200, 'message' => "Thank you for reaching out! Your message has been received and we'll get back to you shortly."], 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['status' => 500, 'message' => 'Internal server error', 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the request's credentials.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function authenticate(): void
|
||||
{
|
||||
$this->ensureIsNotRateLimited();
|
||||
|
||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||
RateLimiter::hit($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the login request is not rate limited.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function ensureIsNotRateLimited(): void
|
||||
{
|
||||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event(new Lockout($this));
|
||||
|
||||
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.throttle', [
|
||||
'seconds' => $seconds,
|
||||
'minutes' => ceil($seconds / 60),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limiting throttle key for the request.
|
||||
*/
|
||||
public function throttleKey(): string
|
||||
{
|
||||
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'lowercase',
|
||||
'email',
|
||||
'max:255',
|
||||
Rule::unique(User::class)->ignore($this->user()->id),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Models/User.php
Normal file
51
app/Models/User.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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 array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'is_admin',
|
||||
'order'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, 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',
|
||||
'is_admin' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
39
app/Providers/AppServiceProvider.php
Normal file
39
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Nwidart\Modules\Facades\Module;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Module::macro('sidebarMenu', function () {
|
||||
return view('components.dashboard.sidebar-menu', [
|
||||
'menus' => config('sidebar'),
|
||||
]);
|
||||
});
|
||||
|
||||
Module::macro('isModuleEnabled', function ($moduleName) {
|
||||
if (Module::has($moduleName)) {
|
||||
$module = Module::find($moduleName);
|
||||
return $module->isStatus(1);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
29
app/Rules/Recaptcha.php
Normal file
29
app/Rules/Recaptcha.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class Recaptcha implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
$gResponseToken = (string) $value;
|
||||
|
||||
$response = Http::asForm()->post(
|
||||
'https://www.google.com/recaptcha/api/siteverify',
|
||||
['secret' => setting('recaptcha_secret_key'), 'response' => $gResponseToken]
|
||||
);
|
||||
|
||||
if (!json_decode($response->body(), true)['success']) {
|
||||
$fail('Invalid recaptcha');
|
||||
}
|
||||
}
|
||||
}
|
||||
28
app/Traits/CreatedUpdatedBy.php
Normal file
28
app/Traits/CreatedUpdatedBy.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait CreatedUpdatedBy
|
||||
{
|
||||
public static function bootCreatedUpdatedBy()
|
||||
{
|
||||
// updating createdby and updatedby when model is created
|
||||
static::creating(function ($model) {
|
||||
if (!$model->isDirty('createdby')) {
|
||||
$model->createdby = auth()->user()->id ?? 1;
|
||||
}
|
||||
if (!$model->isDirty('updatedby')) {
|
||||
$model->updatedby = auth()->user()->id ?? 1;
|
||||
}
|
||||
});
|
||||
|
||||
// updating updatedby when model is updated
|
||||
static::updating(function ($model) {
|
||||
if (!$model->isDirty('updatedby')) {
|
||||
$model->updatedby = auth()->user()->id ?? 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
17
app/View/Components/AppLayout.php
Normal file
17
app/View/Components/AppLayout.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AppLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.app');
|
||||
}
|
||||
}
|
||||
26
app/View/Components/FlashMessage.php
Normal file
26
app/View/Components/FlashMessage.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class FlashMessage extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.flash-message');
|
||||
}
|
||||
}
|
||||
17
app/View/Components/GuestLayout.php
Normal file
17
app/View/Components/GuestLayout.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class GuestLayout extends Component
|
||||
{
|
||||
/**
|
||||
* Get the view / contents that represents the component.
|
||||
*/
|
||||
public function render(): View
|
||||
{
|
||||
return view('layouts.guest');
|
||||
}
|
||||
}
|
||||
26
app/View/Components/ImageInput.php
Normal file
26
app/View/Components/ImageInput.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class ImageInput extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.image-input');
|
||||
}
|
||||
}
|
||||
26
app/View/Components/dashboard/Preloader.php
Normal file
26
app/View/Components/dashboard/Preloader.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\dashboard;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Preloader extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.dashboard.preloader');
|
||||
}
|
||||
}
|
||||
26
app/View/Components/dashboard/RemoveNotificationModal.php
Normal file
26
app/View/Components/dashboard/RemoveNotificationModal.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\dashboard;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class RemoveNotificationModal extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.dashboard.remove-notification-modal');
|
||||
}
|
||||
}
|
||||
28
app/View/Components/dashboard/SidebarMenu.php
Normal file
28
app/View/Components/dashboard/SidebarMenu.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\dashboard;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class SidebarMenu extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View | Closure | string
|
||||
{
|
||||
return view('components.dashboard.sidebar-menu');
|
||||
}
|
||||
}
|
||||
26
app/View/Components/dashboard/ThemeChanger.php
Normal file
26
app/View/Components/dashboard/ThemeChanger.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\dashboard;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class ThemeChanger extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.dashboard.theme-changer');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user