Skip to content

Commit e11e586

Browse files
committed
feat: added auth logic, admin configuration and reset-system pages
1 parent 4ac4c01 commit e11e586

File tree

109 files changed

+8976
-3507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+8976
-3507
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@
44
<a href="https://github.com/lexxyungcarter/laravelte/actions"><img src="https://github.com/lexxyungcarter/laravelte/workflows/tests/badge.svg" alt="Build Status"></a>
55
</p>
66

7+
![Screenshot 1](public/img/laravelte-screenshot-1.jpg)
8+
![Screenshot 1](public/img/laravelte-screenshot-2.jpg)
9+
710

811
## About Laravelte
912

1013
Laravelte is an entire webapp based on the [Laravel](https://laravel.com) web application framework and [Svelte](https://svelte.com) frontend. The main goals of this project is to provide a quick way to get started with your projects.
1114

15+
>NB: In this project, we shift our focus from "What controllers do I need?", "should I make a FormRequest for this?", "should this run asynchronously in a job instead?", etc.
16+
17+
to
18+
> "What does my application actually do?" Kinda like RPC
19+
20+
1221
It features:
1322
- [All Laravel Features](https://laravel.com).
23+
- Light & Dark Mode.
1424
- Quick Frontend Scaffolding via [Svelte](https://svelte.com) via [Inertiajs](https://inertiajs.com). Svelte is extremely fast, and provides less boilerplate as compared to [Vue](https://vuejs.org) and [React](https://react.com).
1525
- Different **Admin** and **User** dashboard support.
1626
- CI/CD via [Github Actions](https://github.com/).

_ide_helper.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18779,26 +18779,6 @@ class Actions {
1877918779
/**
1878018780
*
1878118781
*
18782-
* @param \Lorisleiva\Actions\class-string<JobDecorator> $jobDecoratorClass
18783-
* @static
18784-
*/
18785-
public static function useJobDecorator($jobDecoratorClass)
18786-
{
18787-
return \Lorisleiva\Actions\ActionManager::useJobDecorator($jobDecoratorClass);
18788-
}
18789-
/**
18790-
*
18791-
*
18792-
* @param \Lorisleiva\Actions\class-string<JobDecorator&ShouldBeUnique> $uniqueJobDecoratorClass
18793-
* @static
18794-
*/
18795-
public static function useUniqueJobDecorator($uniqueJobDecoratorClass)
18796-
{
18797-
return \Lorisleiva\Actions\ActionManager::useUniqueJobDecorator($uniqueJobDecoratorClass);
18798-
}
18799-
/**
18800-
*
18801-
*
1880218782
* @static
1880318783
*/
1880418784
public static function setDesignPatterns($designPatterns)

_ide_helper_actions.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ class Dashboard
99
}
1010
namespace App\Actions\Auth;
1111

12+
/**
13+
*/
14+
class Login
15+
{
16+
}
17+
/**
18+
*/
19+
class Logout
20+
{
21+
}
22+
/**
23+
*/
24+
class Register
25+
{
26+
}
27+
namespace App\Actions\Auth\Pages;
28+
1229
/**
1330
*/
1431
class Login
@@ -43,6 +60,22 @@ class Home
4360
class Dashboard
4461
{
4562
}
63+
namespace App\Actions;
64+
65+
/**
66+
* @method static \Lorisleiva\Actions\Decorators\JobDecorator|\Lorisleiva\Actions\Decorators\UniqueJobDecorator makeJob()
67+
* @method static \Lorisleiva\Actions\Decorators\UniqueJobDecorator makeUniqueJob()
68+
* @method static \Illuminate\Foundation\Bus\PendingDispatch dispatch()
69+
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchIf(bool $boolean)
70+
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchUnless(bool $boolean)
71+
* @method static dispatchSync()
72+
* @method static dispatchNow()
73+
* @method static dispatchAfterResponse()
74+
* @method static mixed run()
75+
*/
76+
class UserRedirector
77+
{
78+
}
4679
namespace Lorisleiva\Actions\Concerns;
4780

4881
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Actions\Admin\Settings;
4+
5+
use App\Traits\CustomControllerResponsesTrait;
6+
use App\Traits\ThemesTrait;
7+
use Illuminate\Http\Request;
8+
use Lorisleiva\Actions\Concerns\AsAction;
9+
10+
class Configurations
11+
{
12+
use AsAction;
13+
use ThemesTrait;
14+
use CustomControllerResponsesTrait;
15+
16+
public function asController(Request $request)
17+
{
18+
$data = redis()->get('configurations');
19+
20+
if($request->isMethod('get')) {
21+
return $this->generateBackendPage('Admin/Settings/Configurations', [
22+
'configurations' => $data,
23+
]);
24+
}
25+
}
26+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace App\Actions\Admin\Settings;
4+
5+
use App\Repositories\SystemInfoRepository;
6+
use App\Traits\CustomControllerResponsesTrait;
7+
use App\Traits\ThemesTrait;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Validation\Rule;
10+
use Lorisleiva\Actions\Concerns\AsAction;
11+
12+
class ResetSystem
13+
{
14+
use AsAction;
15+
use ThemesTrait;
16+
use CustomControllerResponsesTrait;
17+
18+
public function asController(Request $request)
19+
{
20+
$actions = [
21+
[
22+
'text' => 'Clear Redis',
23+
'action' => 'redis',
24+
],
25+
[
26+
'text' => 'Clear Cached Views',
27+
'action' => 'views',
28+
],
29+
[
30+
'text' => 'Refresh Configurations (Settings)',
31+
'action' => 'configurations',
32+
],
33+
[
34+
'text' => 'Update Configurations (Settings)',
35+
'action' => 'update-configurations',
36+
],
37+
[
38+
'text' => 'Truncate & Reset Configurations (Settings)',
39+
'action' => 'reset-configurations',
40+
],
41+
[
42+
'text' => 'Run Seeder',
43+
'action' => 'run-seeder',
44+
],
45+
[
46+
'text' => 'Seed Demo Data',
47+
'action' => 'seed-demo-data',
48+
],
49+
];
50+
51+
if($request->isMethod('get')) {
52+
53+
return $this->generateBackendPage('Admin/Settings/ResetSystem', [
54+
'actions' => $actions,
55+
]);
56+
}
57+
58+
$request->validate([
59+
'action' => [
60+
'required',
61+
'string',
62+
Rule::in(collect($actions)->pluck('action')->toArray()),
63+
]
64+
]);
65+
66+
$repo = resolve(SystemInfoRepository::class);
67+
$status = $repo->reset($request->action);
68+
69+
if($status) {
70+
// TODO: event
71+
return $this->respSuccess();
72+
}
73+
74+
return $this->respError();
75+
}
76+
}

app/Actions/Auth/Login.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,6 @@ class Login
2626

2727
public function asController(Request $request)
2828
{
29-
if($request->isMethod('get')) {
30-
$params = [
31-
'canRegister' => setting('allow_user_registrations'),
32-
'canResetPassword' => setting('allow_user_reset_password'),
33-
'oauth_providers' => config('system.providers') ?? []
34-
];
35-
36-
if(isDemo()) {
37-
$params = array_merge([
38-
'username' => config('system.defaults.demo_username'),
39-
'password' => config('system.defaults.demo_password'),
40-
], $params);
41-
}
42-
43-
return $this->generatePage('login', 'Auth/Login', $params);
44-
}
45-
4629
$this->username = $this->findUsername();
4730
$request->validate($this->loginRules(), $this->getValidationMessages());
4831

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Actions\Auth\Pages;
4+
5+
use App\Traits\CustomControllerResponsesTrait;
6+
use App\Traits\ThemesTrait;
7+
use Illuminate\Http\Request;
8+
use Lorisleiva\Actions\Concerns\AsAction;
9+
10+
class ForgotPassword
11+
{
12+
use AsAction;
13+
use CustomControllerResponsesTrait;
14+
use ThemesTrait;
15+
16+
public function asController(Request $request)
17+
{
18+
return $this->generatePage('login', 'Auth/ForgotPassword', [
19+
'title' => 'Request Password Reset'
20+
]);
21+
}
22+
}

app/Actions/Auth/Pages/Login.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Actions\Auth\Pages;
4+
5+
use App\Traits\CustomControllerResponsesTrait;
6+
use App\Traits\ThemesTrait;
7+
use Lorisleiva\Actions\Concerns\AsAction;
8+
9+
class Login
10+
{
11+
use AsAction;
12+
use ThemesTrait;
13+
use CustomControllerResponsesTrait;
14+
15+
public function asController()
16+
{
17+
$params = [
18+
'canRegister' => setting('allow_user_registrations'),
19+
'canResetPassword' => setting('allow_user_reset_password'),
20+
'oauth_providers' => config('system.providers') ?? []
21+
];
22+
23+
if(isDemo()) {
24+
$params = array_merge([
25+
'username' => config('system.defaults.demo_username'),
26+
'password' => config('system.defaults.demo_password'),
27+
], $params);
28+
}
29+
30+
return $this->generatePage('login', 'Auth/Login', $params);
31+
}
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Actions\Auth\Pages;
4+
5+
use App\Traits\CustomControllerResponsesTrait;
6+
use App\Traits\ThemesTrait;
7+
use Lorisleiva\Actions\Concerns\AsAction;
8+
9+
class Register
10+
{
11+
use AsAction;
12+
use ThemesTrait;
13+
use CustomControllerResponsesTrait;
14+
15+
public function asController()
16+
{
17+
$params = [
18+
'canRegister' => setting('allow_user_registrations'),
19+
'oauth_providers' => config('system.providers') ?? []
20+
];
21+
22+
return $this->generatePage('login', 'Auth/Register', $params);
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Actions\Auth\Pages;
4+
5+
use App\Traits\CustomControllerResponsesTrait;
6+
use App\Traits\ThemesTrait;
7+
use Illuminate\Http\Request;
8+
use Lorisleiva\Actions\Concerns\AsAction;
9+
10+
class ResetPassword
11+
{
12+
use AsAction;
13+
use CustomControllerResponsesTrait;
14+
use ThemesTrait;
15+
16+
public function asController(Request $request, $token)
17+
{
18+
return $this->generatePage('login', 'Auth/ResetPassword', [
19+
'token' => $token,
20+
'title' => 'Reset Password'
21+
]);
22+
}
23+
}

0 commit comments

Comments
 (0)