🆙 Add cms i using 🆙

This commit is contained in:
Remco
2025-11-25 22:42:56 +01:00
parent 94704e0925
commit d44196149e
35591 changed files with 3601123 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/*')
->notPath('storage/*')
->notPath('resources/view/mail/*')
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
@@ -0,0 +1,97 @@
# Changelog
All notable changes to `laravel-themer` will be documented in this file.
## 2.3.3 - 2024-05-15
- Fix Update home route to dashboard
## 2.3.2 - 2024-05-15
- Update home route to dashboard
## 2.3.1 - 2024-05-15
- Fix tailwindcss to vite preset
## 2.3.0 - 2024-05-15
- Fix update vite preset dependencies
## 2.2.1 - 2024-03-07
- Fix psalm errors.
## 2.2.0 - 2024-03-07
- Laravel 11.x support.
## 2.1.0 - 2023-02-14
- Laravel 10.x support.
## 2.0.2 - 2022-09-04
- Add build directory in `vite.config.js`.
- Add theme path in `tailwind.config.js` content configuration.
## 2.0.1 - 2022-07-19
- Vue ViteJs plugin upgrade
## 2.0.0 - 2022-07-19
- Add Vite support
- Drop support for Laravel mix
- Drop support for Laravel v7.0, v8.0
## 1.7.1 - 2022-07-19
- Update installation setup in README.md file
## 1.7.0 - 2022-02-11
- Laravel 9.0 support
## 1.6.0 - 2022-01-12
- Tailwind package update
## 1.5.0 - 2021-05-30
- Tailwind and Bootstrap stubs modified
- Tailwind package update
- Drop support for Laravel version 5.8 and 6.x
- .php_cs.dist rename to .php-cs-fixer.dist.php
## 1.4.4 - 2021-02-20
- Bug fix theme solution provider
## 1.4.3 - 2021-02-01
- Video links updated in the `ThemeSolutionProvider`
## 1.4.2 - 2021-01-29
- `Theme::getViewPaths();` method added
- Bug fix on register theme service provider
## 1.4.1 - 2021-01-28
- Validate Vue version, if a specific Vue version is installed then cannot generate a theme for other Vue version.
## 1.4.0 - 2021-01-26
- Added Vue 3 Preset
## 1.3.0 - 2021-01-26
- Refactor code for preset export
- Add `babelConfig` in `webpack.mix.js` for `preset-react` for Mix version 5.x
- Load `tailwind.config.js` from theme directory
## 1.2.3 - 2021-01-23
- Refactoring `AuthScaffolding` trait
- `ThemeBasePathNotDefined` exception
## 1.2.2 - 2021-01-05
- output message on theme command
## 1.2.1 - 2021-01-03
- Documentation link update
## 1.2.0 - 2021-01-03
- theme middleware to set active theme
## 1.1.0 - 2021-01-03
- code refactoring
## 1.0.0 - 2021-01-02
- initial release
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Qirolab
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,173 @@
# Multi theme support for Laravel application
[![Latest Version on Packagist](https://img.shields.io/packagist/v/qirolab/laravel-themer.svg?style=flat-square)](https://packagist.org/packages/qirolab/laravel-themer)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/qirolab/laravel-themer/Tests?label=Tests)](https://github.com/qirolab/laravel-themer/actions?query=workflow%3ATests+branch%3Amaster)
[![Styling](https://github.com/qirolab/laravel-themer/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/qirolab/laravel-themer/actions?query=workflow%3A%22Check+%26+fix+styling%22)
[![Psalm](https://github.com/qirolab/laravel-themer/workflows/Psalm/badge.svg)](https://github.com/qirolab/laravel-themer/actions?query=workflow%3APsalm)
[![Total Downloads](https://img.shields.io/packagist/dt/qirolab/laravel-themer.svg?style=flat-square)](https://packagist.org/packages/qirolab/laravel-themer)
This Laravel package adds multi-theme support to your application. It also provides a simple authentication scaffolding for a starting point for building a Laravel application. And it also has preset for `Bootstrap`, `Tailwind`, `Vue`, and `React`. So, I believe it is a good alternative to the `laravel/ui` & `laravel/breeze` package.
## Features
- Any number of themes
- Fallback theme support (WordPress style); It allows creating a child theme to extend any theme
- Provides authentication scaffolding similar to `laravel/ui` & `laravel/breeze`
- Exports all auth controllers, tests, and other files similar to `laravel/breeze`
- Provides frontend presets for `Bootstrap`, `Tailwind`, `Vue 2`, `Vue 3` and `React`
If you don't want to use auth scaffolding of this package, instead you want to
use Laravel Fortify, no problem with that. You can use Laravel Themer with
Fortify. Laravel Fortify only gives backend implementation authentication, it
does not provide views or frontend presets. So, use Fortify for backend auth and
Laravel Themer for views and presets.
## Tutorial
Here is the video for **[Laravel Themer Tutorial](https://www.youtube.com/watch?v=Ty4ZwFTLYXE)**.
## Installation and setup
> **_NOTE:_**
>
> Laravel Themer v2.x and the above versions support **Vite**.
> If you want to use **Laravel Mix** then try **[Laravel Themer v1.7.1](https://github.com/qirolab/laravel-themer/tree/1.7.1 "v1.7.1")**
You can install this package via composer using:
```bash
composer require qirolab/laravel-themer
```
Publish a configuration file:
```bash
php artisan vendor:publish --provider="Qirolab\Theme\ThemeServiceProvider" --tag="config"
```
## Creating a theme
Run the following command in the terminal:
```bash
php artisan make:theme
```
This command will ask you to enter theme name, CSS framework, js framework, and optional auth scaffolding.
<img src="https://i.imgur.com/HDhORv1.png" alt="Create theme" />
## Useful Theme methods:
```php
// Set active theme
Theme::set('theme-name');
// Get current active theme
Theme::active();
// Get current parent theme
Theme::parent();
// Clear theme. So, no theme will be active
Theme::clear();
// Get theme path
Theme::path($path = 'views');
// output:
// /app-root-path/themes/active-theme/views
Theme::path($path = 'views', $themeName = 'admin');
// output:
// /app-root-path/themes/admin/views
Theme::getViewPaths();
// Output:
// [
// '/app-root-path/themes/admin/views',
// '/app-root-path/resources/views'
// ]
```
## Middleware to set a theme
Register `ThemeMiddleware` in `app\Http\Kernel.php`:
```php
protected $routeMiddleware = [
// ...
'theme' => \Qirolab\Theme\Middleware\ThemeMiddleware::class,
];
```
Examples for middleware usage:
```php
// Example 1: set theme for a route
Route::get('/dashboard', 'DashboardController@index')
->middleware('theme:dashboard-theme');
// Example 2: set theme for a route-group
Route::group(['middleware'=>'theme:admin-theme'], function() {
// "admin-theme" will be applied to all routes defined here
});
// Example 3: set child and parent theme
Route::get('/dashboard', 'DashboardController@index')
->middleware('theme:child-theme,parent-theme');
```
## Asset compilation
To compile the theme assets, first you need to add the following lines in the `scripts` section of the `package.json` file.
```
"scripts": {
...
"dev:theme-name": "vite --config themes/theme-name/vite.config.js",
"build:theme-name": "vite build --config themes/theme-name/vite.config.js"
}
```
Now, to compile a particular theme run the following command:
```bash
npm run dev:theme-name
# or
npm run build:theme-name
```
## Testing
```bash
composer test
```
## Support us
We invest a lot of resources into video tutorials and creating open-source packages. If you like what I do or if you ever made use of something I built or from my videos, consider supporting us. This will allow us to focus even more time on the tutorials and open-source projects we're working on.
<a href="https://www.buymeacoffee.com/qirolab" target="_blank"><img
src="https://i.imgur.com/zHowozE.png" alt="Buy Me A Coffee" style="height: 60px
!important; width: 217px !important;"></a>
Thank you so much for helping us out! 🥰
[![Spec Coder](https://i.imgur.com/lqkt7a3.png)](https://qirolab.com/spec-coder)
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
Authentication scaffolding stubs and presets are taken from [laravel/ui](https://github.com/laravel/ui), [laravel/breeze](https://github.com/laravel/breeze), and [laravel-frontend-presets/tailwindcss](https://github.com/laravel-frontend-presets/tailwindcss).
- [Harish Kumar](https://github.com/hkp22)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
@@ -0,0 +1,65 @@
{
"name": "qirolab/laravel-themer",
"description": "A Laravel theme manager, that will help you organize and maintain your themes inside Laravel projects.",
"keywords": [
"qirolab",
"laravel-theme",
"theme",
"laravel"
],
"homepage": "https://qirolab.com",
"license": "MIT",
"authors": [
{
"name": "Harish Kumar",
"email": "harish@qirolab.com",
"homepage": "https://qirolab.com",
"role": "Developer"
}
],
"require": {
"php": ">=7.1.0",
"facade/ignition-contracts": "^1.0",
"illuminate/support": "^9.19|^10.0|^11.0|^12.0"
},
"require-dev": {
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
"phpunit/phpunit": "^8.3|^9.0|^10.5|^11.5.3",
"vimeo/psalm": "^4.0|^5.22|^6.7"
},
"autoload": {
"psr-4": {
"Qirolab\\Theme\\": "src",
"Qirolab\\Theme\\Database\\Factories\\": "database/factories"
}
},
"autoload-dev": {
"psr-4": {
"Qirolab\\Theme\\Tests\\": "tests"
}
},
"scripts": {
"psalm": "vendor/bin/psalm",
"test": "vendor/bin/phpunit --colors=always",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"Qirolab\\Theme\\ThemeServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"funding": [
{
"type": "other",
"url": "https://www.buymeacoffee.com/qirolab"
}
]
}
@@ -0,0 +1,34 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Active Theme
|--------------------------------------------------------------------------
|
| It will assign the default active theme to be used if one is not set during
| runtime.
*/
'active' => null,
/*
|--------------------------------------------------------------------------
| Parent Theme
|--------------------------------------------------------------------------
|
| This is a parent theme for the theme specified in the active config
| option. It works like the WordPress style theme hierarchy, if the blade
| file is not found in the currently active theme, then it will look for it
| in the parent theme.
*/
'parent' => null,
/*
|--------------------------------------------------------------------------
| Base Path
|--------------------------------------------------------------------------
|
| The base path where all the themes are located.
*/
'base_path' => base_path('themes')
];
@@ -0,0 +1,6 @@
{
"name": "laravel-theme",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}
@@ -0,0 +1,207 @@
<?php
namespace Qirolab\Theme\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
use Qirolab\Theme\Enums\CssFramework;
use Qirolab\Theme\Enums\JsFramework;
use Qirolab\Theme\Presets\Traits\AuthScaffolding;
use Qirolab\Theme\Presets\Traits\PackagesTrait;
use Qirolab\Theme\Presets\Traits\StubTrait;
use Qirolab\Theme\Presets\Vite\VitePresetExport;
class MakeThemeCommand extends Command
{
use AuthScaffolding;
use PackagesTrait;
use StubTrait;
/**
* @var string
*/
public $signature = 'make:theme {theme?}';
/**
* @var string
*/
public $description = 'Create a new theme';
/**
* @var string
*/
public $theme;
/**
* @var string
*/
public $themePath;
/**
* @var string
*/
public $cssFramework;
/**
* @var string
*/
public $jsFramework;
public function handle(): void
{
$this->theme = $this->askTheme();
if (! $this->themeExists($this->theme)) {
$this->cssFramework = $this->askCssFramework();
$this->jsFramework = $this->askJsFramework();
$authScaffolding = $this->askAuthScaffolding();
(new VitePresetExport(
$this->theme,
$this->cssFramework,
$this->jsFramework
))
->export();
$this->exportAuthScaffolding($authScaffolding);
$this->line("<options=bold>Theme Name:</options=bold> {$this->theme}");
$this->line("<options=bold>CSS Framework:</options=bold> {$this->cssFramework}");
$this->line("<options=bold>JS Framework:</options=bold> {$this->jsFramework}");
$this->line("<options=bold>Auth Scaffolding:</options=bold> {$authScaffolding}");
$this->line('');
$this->info("Theme scaffolding installed successfully.\n");
$themePath = $this->relativeThemePath($this->theme);
$scriptDevCmd = ' "dev:'.$this->theme.'": "vite --config '.$themePath.'/vite.config.js",';
$scriptBuildCmd = ' "build:'.$this->theme.'": "vite build --config '.$themePath.'/vite.config.js"';
$this->comment('Add following line in the `<fg=blue>scripts</fg=blue>` section of the `<fg=blue>package.json</fg=blue>` file:');
$this->line('');
$this->line('"scripts": {', 'fg=magenta');
$this->line(' ...', 'fg=magenta');
$this->line('');
$this->line($scriptDevCmd, 'fg=magenta');
$this->line($scriptBuildCmd, 'fg=magenta');
$this->line('}');
$this->line('');
$this->comment('And please run `<fg=blue>npm install && npm run dev:'.$this->theme.'</fg=blue>` to compile your fresh scaffolding.');
}
}
protected function askTheme()
{
$theme = $this->argument('theme');
if (! $theme) {
$theme = $this->askValid(
'Name of your theme',
'theme',
['required']
);
}
return $theme;
}
protected function askCssFramework()
{
$options = [
CssFramework::Bootstrap,
CssFramework::Tailwind,
'Skip',
];
$cssFramework = $this->choice(
'Select CSS Framework',
$options,
$_default = $options[0],
$_maxAttempts = null,
$_allowMultipleSelections = false
);
return $cssFramework;
}
protected function askJsFramework()
{
$options = [
JsFramework::Vue3,
JsFramework::React,
'Skip',
];
$jsFramework = $this->choice(
'Select Javascript Framework',
$options,
$_default = $options[0], // Default value
$_maxAttempts = null,
$_allowMultipleSelections = false
);
return $jsFramework;
}
public function askAuthScaffolding()
{
$options = [
'Views Only',
'Controllers & Views',
'Skip',
];
$authScaffolding = $this->choice(
'Publish Auth Scaffolding',
$options,
$_default = $options[0],
$_maxAttempts = null,
$_allowMultipleSelections = false
);
return $authScaffolding;
}
protected function themeExists(string $theme): bool
{
$directory = config('theme.base_path').DIRECTORY_SEPARATOR.$theme;
if (is_dir($directory)) {
$this->error("`{$theme}` theme already exists.");
return true;
}
return false;
}
protected function askValid(string $question, string $field, array $rules)
{
$value = $this->ask($question);
if ($message = $this->validateInput($rules, $field, $value)) {
$this->error($message);
return $this->askValid($question, $field, $rules);
}
return $value;
}
protected function validateInput($rules, $fieldName, $value): ?string
{
$validator = Validator::make([
$fieldName => $value,
], [
$fieldName => $rules,
]);
return $validator->fails()
? $validator->errors()->first($fieldName)
: null;
}
}
@@ -0,0 +1,9 @@
<?php
namespace Qirolab\Theme\Enums;
class CssFramework
{
const Bootstrap = 'Bootstrap';
const Tailwind = 'Tailwind';
}
@@ -0,0 +1,9 @@
<?php
namespace Qirolab\Theme\Enums;
class JsFramework
{
const Vue3 = 'Vue 3';
const React = 'React';
}
@@ -0,0 +1,13 @@
<?php
namespace Qirolab\Theme\Exceptions;
use Exception;
class ThemeBasePathNotDefined extends Exception
{
public function __construct()
{
parent::__construct('Theme base path is not defined');
}
}
@@ -0,0 +1,24 @@
<?php
namespace Qirolab\Theme\Middleware;
use Closure;
use Illuminate\Http\Request;
use Qirolab\Theme\Theme;
class ThemeMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next, string $theme, string $parentTheme = null)
{
Theme::set($theme, $parentTheme);
return $next($request);
}
}
@@ -0,0 +1,184 @@
<?php
namespace Qirolab\Theme\Presets\Traits;
use Qirolab\Theme\Enums\CssFramework;
use Qirolab\Theme\Enums\JsFramework;
use Qirolab\Theme\Theme;
trait AuthScaffolding
{
use HandleFiles;
use StubTrait;
public function themePath($path = '')
{
return Theme::path($path, $this->theme);
}
public function exportAuthScaffolding(string $authScaffolding = 'Views Only'): void
{
if ($authScaffolding == 'Controllers & Views') {
$this->exportControllers()
->exportComponents()
->exportRequests()
->exportViews()
->exportRoutes()
->exportTests();
}
if ($authScaffolding == 'Views Only') {
$this->exportViews();
}
}
public function exportControllers(): self
{
$this->ensureDirectoryExists(app_path('Http/Controllers/Auth'));
$controllers = [
'app/Http/Controllers/Auth/AuthenticatedSessionController.php',
'app/Http/Controllers/Auth/ConfirmablePasswordController.php',
'app/Http/Controllers/Auth/EmailVerificationNotificationController.php',
'app/Http/Controllers/Auth/EmailVerificationPromptController.php',
'app/Http/Controllers/Auth/NewPasswordController.php',
'app/Http/Controllers/Auth/PasswordResetLinkController.php',
'app/Http/Controllers/Auth/RegisteredUserController.php',
'app/Http/Controllers/Auth/VerifyEmailController.php',
];
$this->publishFiles($controllers);
return $this;
}
public function exportComponents(): self
{
$this->ensureDirectoryExists(app_path('View/Components'));
$components = [
'app/View/Components/AppLayout.php',
'app/View/Components/GuestLayout.php',
];
$this->publishFiles($components);
return $this;
}
protected function exportRequests(): self
{
$this->ensureDirectoryExists(app_path('Http/Requests/Auth'));
$files = [
'app/Http/Requests/Auth/LoginRequest.php',
];
$this->publishFiles($files);
return $this;
}
public function exportViews(): self
{
$this->ensureDirectoryExists(Theme::path('views', $this->theme));
$this->copyDirectory(
__DIR__."/../../../stubs/resources/{$this->cssFramework}/views",
Theme::path('views', $this->theme)
);
$themePath = $this->relativeThemePath($this->theme);
$cssPath = $themePath.($this->cssFramework === CssFramework::Bootstrap ? '/sass/app.scss' : '/css/app.css');
$jsPath = $themePath.'/js/app.js';
$viteConfig = "@vite(['".$cssPath."', '".$jsPath."'], '".$this->theme."')";
if ($this->jsFramework === JsFramework::React) {
$viteConfig = '@viteReactRefresh'."\n ".$viteConfig;
}
$this->replaceInFile('%vite%', $viteConfig, Theme::path('views/layouts/app.blade.php', $this->theme));
$this->replaceInFile('%vite%', $viteConfig, Theme::path('views/layouts/guest.blade.php', $this->theme));
return $this;
}
public function exportRoutes(): self
{
$routeFile = 'routes/auth.php';
$overwrite = false;
if (file_exists(base_path($routeFile))) {
$overwrite = $this->confirm(
"<fg=red>{$routeFile} already exists.</fg=red>\n ".
'Do you want to overwrite?',
false
);
}
if (! file_exists(base_path($routeFile)) || $overwrite) {
copy(__DIR__.'/../../../stubs/routes/auth.php', base_path('routes/auth.php'));
$homeRoute = "
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth'])->name('dashboard');
";
$requireAuth = "require __DIR__.'/auth.php';";
if (! exec('grep '.escapeshellarg($requireAuth).' '.base_path('routes/web.php'))) {
$this->append(
base_path('routes/web.php'),
$homeRoute.$requireAuth
);
}
}
return $this;
}
public function exportTests(): self
{
$this->ensureDirectoryExists(base_path('tests/Feature'));
$testFiles = [
'tests/Feature/AuthenticationTest.php',
'tests/Feature/EmailVerificationTest.php',
'tests/Feature/PasswordConfirmationTest.php',
'tests/Feature/PasswordResetTest.php',
'tests/Feature/RegistrationTest.php',
];
$this->publishFiles($testFiles);
return $this;
}
protected function publishFiles(array $files): void
{
foreach ($files as $file) {
$publishPath = base_path($file);
$overwrite = false;
if (file_exists($publishPath)) {
$overwrite = $this->confirm(
"<fg=red>{$file} already exists.</fg=red>\n ".
'Do you want to overwrite?',
false
);
}
if (! file_exists($publishPath) || $overwrite) {
copy(
__DIR__.'/../../../stubs/'.$file,
$publishPath
);
}
}
}
}
@@ -0,0 +1,48 @@
<?php
namespace Qirolab\Theme\Presets\Traits;
use Illuminate\Filesystem\Filesystem;
trait HandleFiles
{
/**
* Ensure a directory exists.
*
* @param string $path
* @param int $mode
* @param bool $recursive
* @return void
*/
protected function ensureDirectoryExists(string $path, int $mode = 0755, bool $recursive = true)
{
if (! (new Filesystem())->isDirectory($path)) {
(new Filesystem())->makeDirectory($path, $mode, $recursive);
}
}
protected function replaceInFile(string $search, string $replace, string $path): bool
{
return (bool) file_put_contents($path, str_replace($search, $replace, file_get_contents($path)));
}
public function createFile(string $path, string $content = ''): bool
{
return (bool) file_put_contents($path, $content);
}
public function append(string $path, string $data): bool
{
return (bool) file_put_contents($path, $data, FILE_APPEND);
}
public function copyDirectory(string $directory, string $destination, $options = null): bool
{
return (new Filesystem())->copyDirectory($directory, $destination, $options);
}
public function exists(string $path): bool
{
return file_exists($path);
}
}
@@ -0,0 +1,121 @@
<?php
namespace Qirolab\Theme\Presets\Traits;
trait PackagesTrait
{
public function getPackages()
{
if (! file_exists(base_path('package.json'))) {
return;
}
return json_decode(file_get_contents(base_path('package.json')), true);
}
/**
* Update the "package.json" file.
*
* @param bool $dev
*
* @return null|$this
*/
protected function updatePackages($dev = true)
{
if ($packages = $this->getPackages()) {
$configurationKey = $dev ? 'devDependencies' : 'dependencies';
$packages[$configurationKey] = static::updatePackageArray(
array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : []
);
ksort($packages[$configurationKey]);
file_put_contents(
base_path('package.json'),
json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL
);
return $this;
}
return null;
}
/**
* @param string $package
* @param bool $dev
* @return null|string
*/
public function getPackageVersion($package, $dev = true)
{
if ($packages = $this->getPackages()) {
$configurationKey = $dev ? 'devDependencies' : 'dependencies';
$version = $packages[$configurationKey][$package] ?? null;
return $this->getVersion($version);
}
return null;
}
/**
* @param string $str
* @return null|string
*/
protected function getVersion($str)
{
preg_match("/\s*((?:[0-9]+\.?)+)/i", $str, $matches);
return $matches[1] ?? null;
}
/**
* @param bool $dev
* @return null|string
*/
public function getMixVersion($dev = true)
{
return $this->getPackageVersion('laravel-mix', $dev);
}
/**
* @param bool $dev
* @return null|string
*/
public function getVueVersion($dev = true)
{
return $this->getPackageVersion('vue', $dev);
}
/**
* @param string $actual
* @param string $compare
* @return bool
*/
public function versionLessThan($actual, $compare)
{
return version_compare($actual, $compare, '<');
}
/**
* @param string $actual
* @param string $compare
* @return bool
*/
public function versionGreaterThan($actual, $compare)
{
return version_compare($actual, $compare, '>');
}
/**
* @param string $actual
* @param string $compare
* @return bool
*/
public function versionGreaterOrEqual($actual, $compare)
{
return version_compare($actual, $compare, '>=');
}
}
@@ -0,0 +1,37 @@
<?php
namespace Qirolab\Theme\Presets\Traits;
use Qirolab\Theme\Presets\Vite\VitePresetExport;
use Qirolab\Theme\Theme;
trait PresetTrait
{
use HandleFiles;
use PackagesTrait;
/**
* @var VitePresetExport
*/
public $exporter;
public function __construct(VitePresetExport $exporter)
{
$this->exporter = $exporter;
}
public function getTheme(): string
{
return $this->exporter->getTheme();
}
public function themePath($path = '')
{
return Theme::path($path, $this->getTheme());
}
public function jsPreset()
{
return $this->exporter->jsPreset();
}
}
@@ -0,0 +1,20 @@
<?php
namespace Qirolab\Theme\Presets\Traits;
use Qirolab\Theme\Theme;
trait StubTrait
{
public function stubPath(string $file): string
{
return __DIR__.'/../../../stubs/Presets/'.$file;
}
public function relativeThemePath($theme)
{
$themePath = str_replace(base_path(), '', Theme::path('', $theme));
return ltrim($themePath, DIRECTORY_SEPARATOR);
}
}
@@ -0,0 +1,86 @@
<?php
namespace Qirolab\Theme\Presets\Vite;
use Qirolab\Theme\Presets\Traits\PresetTrait;
use Qirolab\Theme\Presets\Traits\StubTrait;
class BootstrapPreset
{
use PresetTrait;
use StubTrait;
public function export(): void
{
$this->updatePackages()
->exportSass()
->exportJs();
}
/**
* Update the given package array.
*
* @param array $packages
* @return array
*/
protected static function updatePackageArray(array $packages): array
{
return [
'bootstrap' => '^4.6.0',
'jquery' => '^3.5',
'popper.js' => '^1.16',
'sass' => '^1.32.1',
'sass-loader' => '^10.1.1',
] + $packages;
}
/**
* Update the bootstrapping files.
*
* @return $this
*/
protected function exportJs()
{
$this->ensureDirectoryExists($this->themePath('js'));
copy(
$this->stubPath('bootstrap-stubs/js/bootstrap.js'),
$this->themePath('js/bootstrap.js')
);
copy(
$this->stubPath('bootstrap-stubs/js/app.js'),
$this->themePath('js/app.js')
);
return $this;
}
/**
* Update the Sass files for the application.
*
* @return $this
*/
protected function exportSass()
{
$this->ensureDirectoryExists($this->themePath('sass'));
copy(
$this->stubPath('bootstrap-stubs/sass/_variables.scss'),
$this->themePath('sass/_variables.scss')
);
copy(
$this->stubPath('bootstrap-stubs/sass/app.scss'),
$this->themePath('sass/app.scss')
);
return $this;
}
public function updateViteConfig($configData)
{
$configData = str_replace('%app_css_input%', 'sass/app.scss', $configData);
$bootstrap = "'~bootstrap': path.resolve('node_modules/bootstrap'),";
return str_replace('%bootstrap%', $bootstrap, $configData);
}
}
@@ -0,0 +1,89 @@
<?php
namespace Qirolab\Theme\Presets\Vite;
use Qirolab\Theme\Presets\Traits\PresetTrait;
use Qirolab\Theme\Presets\Traits\StubTrait;
class ReactPreset
{
use PresetTrait;
use StubTrait;
public function export(): void
{
$this->updatePackages()
->exportReactComponent()
->exportJs();
}
/**
* Update the given package array.
*
* @param array $packages
* @return array
*/
protected static function updatePackageArray(array $packages): array
{
return [
'@vitejs/plugin-react' => '^1.3.2',
// '@babel/preset-react' => '^7.18.6',
'react' => '^18.2.0',
'react-dom' => '^18.2.0',
] + $packages;
// return [
// '@babel/preset-react' => '^7.0.0',
// 'react' => '^16.2.0',
// 'react-dom' => '^16.2.0',
// ] + Arr::except($packages, ['vue', 'vue-template-compiler']);
}
/**
* Update the bootstrapping files.
*
* @return $this
*/
protected function exportJs()
{
copy($this->stubPath('react-stubs/app.js'), $this->themePath('js/app.js'));
if (! $this->exists($this->themePath('js/bootstrap.js'))) {
copy($this->stubPath('react-stubs/bootstrap.js'), $this->themePath('js/bootstrap.js'));
}
// if (!$this->exists(base_path('.babelrc'))) {
// copy(__DIR__ . '/../../stubs/Presets/react-stubs/.babelrc', base_path('.babelrc'));
// }
return $this;
}
/**
* Update the example component.
*
* @return $this
*/
protected function exportReactComponent()
{
$this->ensureDirectoryExists($this->themePath('js/components'));
copy(
$this->stubPath('react-stubs/Example.jsx'),
$this->themePath('js/components/Example.jsx')
);
return $this;
}
public function updateViteConfig($configData)
{
$reactImport = "import react from '@vitejs/plugin-react';";
$reactConfig = 'react(),';
$configData = str_replace('%react_import%', $reactImport, $configData);
$configData = str_replace('%react_plugin_config%', $reactConfig, $configData);
return $configData;
}
}
@@ -0,0 +1,91 @@
<?php
namespace Qirolab\Theme\Presets\Vite;
use Qirolab\Theme\Presets\Traits\PresetTrait;
use Qirolab\Theme\Presets\Traits\StubTrait;
class TailwindPreset
{
use PresetTrait;
use StubTrait;
public function export(): void
{
$this->updatePackages()
->exportBootstrapping();
}
/**
* Update the given package array.
*
* @param array $packages
* @return array
*/
protected static function updatePackageArray(array $packages): array
{
return [
'@tailwindcss/forms' => '^0.5.7',
'autoprefixer' => '^10.4.19',
'postcss' => '^8.4.38',
'postcss-import' => '^16.1.0',
'tailwindcss' => '^3.4.3',
] + $packages;
}
/**
* Update the bootstrapping files.
*
* @return $this
*/
protected function exportBootstrapping()
{
$this->ensureDirectoryExists($this->themePath('js'));
$this->ensureDirectoryExists($this->themePath('css'));
copy($this->stubPath('tailwind-stubs/tailwind.config.js'), $this->themePath('tailwind.config.js'));
$this->replaceInFile(
'%theme_path%',
$this->relativeThemePath($this->getTheme()),
$this->themePath('tailwind.config.js')
);
if (! $this->exists($this->themePath('js/app.js'))) {
copy(
$this->stubPath('tailwind-stubs/js/app.js'),
$this->themePath('js/app.js')
);
}
if (! $this->exists($this->themePath('js/bootstrap.js'))) {
copy(
$this->stubPath('tailwind-stubs/js/bootstrap.js'),
$this->themePath('js/bootstrap.js')
);
}
copy($this->stubPath('tailwind-stubs/css/app.css'), $this->themePath('css/app.css'));
return $this;
}
public function getViteConfig()
{
return 'css: {
postcss: {
plugins: [
tailwindcss({
config: path.resolve(__dirname, "tailwind.config.js"),
}),
],
},
},';
}
public function updateViteConfig($configData)
{
$configData = str_replace('%app_css_input%', 'css/app.css', $configData);
$configData = str_replace('%tailwind_import%', 'import tailwindcss from "tailwindcss";', $configData);
return str_replace('%css_config%', $this->getViteConfig(), $configData);
}
}
@@ -0,0 +1,115 @@
<?php
namespace Qirolab\Theme\Presets\Vite;
use Qirolab\Theme\Presets\Traits\HandleFiles;
use Qirolab\Theme\Presets\Traits\StubTrait;
use Qirolab\Theme\Theme;
class VitePresetExport
{
use HandleFiles;
use StubTrait;
/**
* @var string
*/
protected $theme;
/**
* @var string
*/
public $cssFramework;
/**
* @var string
*/
public $jsFramework;
public function __construct(string $theme, string $cssFramework, string $jsFramework)
{
$this->theme = $theme;
$this->cssFramework = $cssFramework;
$this->jsFramework = $jsFramework;
$this->ensureDirectoryExists(Theme::path('', $theme));
}
public function getTheme(): string
{
return $this->theme;
}
public function export(): void
{
if ($this->cssPreset()) {
$this->cssPreset()->export();
}
if ($this->jsPreset()) {
$this->jsPreset()->export();
}
$this->exportViteConfig();
}
public function getPreset($preset)
{
$preset = str_replace(' ', '', $preset);
$presetClass = "\\Qirolab\\Theme\\Presets\\Vite\\{$preset}Preset";
if (class_exists($presetClass)) {
return new $presetClass($this);
}
}
public function cssPreset()
{
return $this->getPreset($this->cssFramework);
}
/**
* @return null|object
*/
public function jsPreset()
{
return $this->getPreset($this->jsFramework);
}
public function exportViteConfig()
{
$placeHolders = [
'%app_css_input%',
'%theme_path%',
'%theme_name%',
'%css_config%',
'%tailwind_import%',
'%vue_import%',
'%vue_plugin_config%',
'%react_import%',
'%react_plugin_config%',
'%bootstrap%',
];
$themePath = $this->relativeThemePath($this->theme);
$configData = file_get_contents($this->stubPath('vite.config.js'));
$configData = str_replace('%theme_path%', $themePath.DIRECTORY_SEPARATOR, $configData);
$configData = str_replace('%theme_name%', $this->theme, $configData);
if ($this->cssPreset()) {
$configData = $this->cssPreset()->updateViteConfig($configData);
}
if ($this->jsPreset()) {
$configData = $this->jsPreset()->updateViteConfig($configData);
}
foreach ($placeHolders as $placeHolder) {
$configData = str_replace($placeHolder, '', $configData);
}
$this->createFile(Theme::path('vite.config.js', $this->theme), $configData);
}
}
@@ -0,0 +1,101 @@
<?php
namespace Qirolab\Theme\Presets\Vite;
use Qirolab\Theme\Presets\Traits\PresetTrait;
use Qirolab\Theme\Presets\Traits\StubTrait;
class Vue3Preset
{
use PresetTrait;
use StubTrait;
public function export(): void
{
$this->updatePackages()
->exportVueComponent()
->exportJs();
}
/**
* Update the given package array.
*
* @param array $packages
* @return array
*/
protected static function updatePackageArray(array $packages): array
{
return [
'@vitejs/plugin-vue' => '^5.0.4',
// '@vue/compiler-sfc' => '^3.2.37',
// 'resolve-url-loader' => '^5.0.0',
// 'sass' => '^1.53.0',
// 'sass-loader' => '^13.0.2',
'vue' => '^3.4.27',
// 'vue-loader' => '^17.0.0',
] + $packages;
// return [
// 'resolve-url-loader' => '^2.3.1',
// 'sass' => '^1.20.1',
// 'sass-loader' => '^8.0.0',
// 'vue' => '^2.5.17',
// 'vue-template-compiler' => '^2.6.10',
// ] + Arr::except($packages, [
// '@babel/preset-react',
// 'react',
// 'react-dom',
// ]);
}
/**
* Update the bootstrapping files.
*
* @return $this
*/
protected function exportJs()
{
copy($this->stubPath('vue3-stubs/app.js'), $this->themePath('js/app.js'));
if (! $this->exists($this->themePath('js/bootstrap.js'))) {
copy($this->stubPath('vue3-stubs/bootstrap.js'), $this->themePath('js/bootstrap.js'));
}
return $this;
}
/**
* Update the example component.
*
* @return $this
*/
protected function exportVueComponent()
{
$this->ensureDirectoryExists($this->themePath('js/components'));
copy(
$this->stubPath('vue3-stubs/ExampleComponent.vue'),
$this->themePath('js/components/ExampleComponent.vue')
);
return $this;
}
public function updateViteConfig($configData)
{
$vueImport = "import vue from '@vitejs/plugin-vue';";
$vueConfig = 'vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),';
$configData = str_replace('%vue_import%', $vueImport, $configData);
$configData = str_replace('%vue_plugin_config%', $vueConfig, $configData);
return $configData;
}
}
@@ -0,0 +1,52 @@
<?php
namespace Qirolab\Theme\SolutionProviders;
use Facade\IgnitionContracts\BaseSolution;
use Facade\IgnitionContracts\HasSolutionsForThrowable;
use Qirolab\Theme\Theme;
use Throwable;
class ThemeSolutionProvider implements HasSolutionsForThrowable
{
public function canSolve(Throwable $throwable): bool
{
return true;
}
public function getSolutions(Throwable $throwable): array
{
$message = $this->getMessage();
if (app()->runningInConsole() || ! $message) {
return [];
}
return [
BaseSolution::create('Theme')
->setSolutionDescription($message)
->setDocumentationLinks([
'Documentation' => 'https://github.com/qirolab/laravel-themer',
'Video Tutorial' => 'https://www.youtube.com/watch?v=Ty4ZwFTLYXE',
]),
];
}
public function getMessage(): string
{
$message = '';
$activeTheme = Theme::active();
$parentTheme = Theme::parent();
if ($activeTheme) {
$message = "**Active Theme:** `{$activeTheme}` ";
}
if ($parentTheme) {
$message .= "**Parent Theme:** `{$parentTheme}`";
}
return $message;
}
}
@@ -0,0 +1,62 @@
<?php
namespace Qirolab\Theme;
class Theme
{
public static function finder()
{
return app('theme.finder');
}
public static function set(string $theme, string $parentTheme = null): void
{
self::finder()->setActiveTheme($theme, $parentTheme);
}
public static function clear(): void
{
self::finder()->clearThemes();
}
public static function active(): ?string
{
return self::finder()->getActiveTheme();
}
public static function parent(): ?string
{
return self::finder()->getParentTheme();
}
public static function viewPath(string $theme = null): ?string
{
$theme = $theme ?? self::active();
if ($theme) {
return self::finder()->getThemeViewPath($theme);
}
return null;
}
public static function path(string $path = null, string $theme = null): ?string
{
$theme = $theme ?? self::active();
if ($theme) {
return self::finder()->getThemePath($theme, $path);
}
return null;
}
public static function getViewPaths(): array
{
if (self::finder()) {
return self::finder()->getViewFinder()->getPaths();
}
return app('view')->getFinder()->getPaths();
}
}
@@ -0,0 +1,80 @@
<?php
namespace Qirolab\Theme;
use Facade\IgnitionContracts\SolutionProviderRepository;
// use Illuminate\Container\Container;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\ServiceProvider;
use Qirolab\Theme\Commands\MakeThemeCommand;
use Qirolab\Theme\SolutionProviders\ThemeSolutionProvider;
class ThemeServiceProvider extends ServiceProvider
{
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__.'/../config/theme.php' => config_path('theme.php'),
], 'config');
$this->commands([
MakeThemeCommand::class,
]);
}
}
public function register()
{
$this->mergeConfig();
$this->registerThemeFinder();
$this->registerSolutionProvider();
}
protected function mergeConfig(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/theme.php', 'theme');
}
protected function registerSolutionProvider(): void
{
try {
$solutionProvider = $this->app->make(SolutionProviderRepository::class);
$solutionProvider->registerSolutionProvider(
ThemeSolutionProvider::class
);
} catch (BindingResolutionException $error) {
}
}
protected function registerThemeFinder(): void
{
$this->app->singleton('theme.finder', function ($app) {
$themeFinder = new ThemeViewFinder(
$app['files'],
$app['config']['view.paths']
);
// $themeFinder = new ThemeViewFinder(
// Container::getInstance()->make('files'),
// Container::getInstance()->make('config')['view.paths']
// );
$themeFinder->setHints(
$this->app->make('view')->getFinder()->getHints()
);
return $themeFinder;
});
if (config('theme.active')) {
$this->app->make('theme.finder')->setActiveTheme(config('theme.active'), config('theme.parent'));
}
// If need to replace Laravel's view finder with package's theme.finder
// $this->app->make('view')->setFinder($this->app->make('theme.finder'));
}
}
@@ -0,0 +1,134 @@
<?php
namespace Qirolab\Theme;
use Illuminate\View\FileViewFinder;
use Qirolab\Theme\Exceptions\ThemeBasePathNotDefined;
class ThemeViewFinder extends FileViewFinder
{
/**
* @var null|string
*/
protected $activeTheme;
/**
* @var null|string
*/
protected $parentTheme;
public function getViewFinder()
{
// It should return `theme.finder` if Laravel's view finder is replaced
// with package's finder.
// return app('theme.finder');
return app('view')->getFinder();
}
public function setActiveTheme(string $theme, string $parentTheme = null): void
{
if ($theme) {
$this->clearThemes();
if ($parentTheme) {
$this->registerTheme($parentTheme);
$this->parentTheme = $parentTheme;
}
$this->registerTheme($theme);
$this->activeTheme = $theme;
}
}
public function setHints($hints): void
{
$this->hints = $hints;
}
public function getThemePath(string $theme, string $path = null): string
{
if (! config('theme.base_path')) {
throw new ThemeBasePathNotDefined();
}
return $this->resolvePath(
config('theme.base_path') . DIRECTORY_SEPARATOR . $theme . ($path ? DIRECTORY_SEPARATOR . $path : '')
);
}
public function getThemeViewPath(string $theme = null): string
{
$theme = $theme ?? $this->getActiveTheme();
return $this->getThemePath($theme, 'views');
}
/**
* Get active theme name.
*
* @return null|string
*/
public function getActiveTheme()
{
return $this->activeTheme;
}
/**
* Get parent theme name.
*
* @return null|string
*/
public function getParentTheme()
{
return $this->parentTheme;
}
public function clearThemes(): void
{
$paths = $this->getViewFinder()->getPaths();
if ($this->getActiveTheme()) {
if (($key = array_search($this->getThemeViewPath($this->getActiveTheme()), $paths)) !== false) {
unset($paths[$key]);
}
}
if ($this->getParentTheme()) {
if (($key = array_search($this->getThemeViewPath($this->getParentTheme()), $paths)) !== false) {
unset($paths[$key]);
}
}
$this->activeTheme = null;
$this->parentTheme = null;
$this->getViewFinder()->setPaths($paths);
}
public function registerTheme(string $theme): void
{
// array_unshift($this->paths, $this->getThemeViewPath($theme));
$this->getViewFinder()->prependLocation($this->getThemeViewPath($theme));
$this->registerNameSpacesForTheme($theme);
}
public function registerNameSpacesForTheme(string $theme): void
{
$vendorViewsPath = $this->getThemeViewPath($theme) . DIRECTORY_SEPARATOR . 'vendor';
if (is_dir($vendorViewsPath)) {
$directories = scandir($vendorViewsPath);
foreach ($directories as $namespace) {
if ($namespace != '.' && $namespace != '..') {
$path = $vendorViewsPath . DIRECTORY_SEPARATOR . $namespace;
$this->getViewFinder()->prependNamespace($namespace, $path);
}
}
}
}
}
@@ -0,0 +1,7 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
import "./bootstrap";
@@ -0,0 +1,48 @@
import _ from "lodash";
window._ = _;
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
import * as Popper from "popper.js";
window.Popper = Popper;
import jquery from "jquery";
window.$ = window.jQuery = jquery;
// Import all of Bootstrap's JS
import * as bootstrap from "bootstrap";
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
// window.Pusher = Pusher;
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: import.meta.env.VITE_PUSHER_APP_KEY,
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_CLUSTER}.pusher.com`,
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
// enabledTransports: ['ws', 'wss'],
// });
@@ -0,0 +1,19 @@
// Body
$body-bg: #f8fafc;
// Typography
$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;
// Colors
$blue: #3490dc;
$indigo: #6574cd;
$purple: #9561e2;
$pink: #f66d9b;
$red: #e3342f;
$orange: #f6993f;
$yellow: #ffed4a;
$green: #38c172;
$teal: #4dc0b5;
$cyan: #6cb2eb;
@@ -0,0 +1,8 @@
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
// Variables
@import 'variables';
// Bootstrap
@import '~bootstrap/scss/bootstrap';
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-react"]
}
@@ -0,0 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom';
function Example() {
return (
<div className="container">
<div className="row justify-content-center">
<div className="col-md-8">
<div className="card">
<div className="card-header">Example Component</div>
<div className="card-body">I'm an example component!</div>
</div>
</div>
</div>
</div>
);
}
export default Example;
if (document.getElementById('example')) {
ReactDOM.render(<Example />, document.getElementById('example'));
}
@@ -0,0 +1,15 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes React and other helpers. It's a great starting point while
* building robust, powerful web applications using React + Laravel.
*/
import "./bootstrap";
/**
* Next, we will create a fresh React component instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
import "./components/Example.jsx";
@@ -0,0 +1,34 @@
import _ from "lodash";
window._ = _;
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
// window.Pusher = Pusher;
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: import.meta.env.VITE_PUSHER_APP_KEY,
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_CLUSTER}.pusher.com`,
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
// enabledTransports: ['ws', 'wss'],
// });
@@ -0,0 +1,5 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
@@ -0,0 +1,7 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
import "./bootstrap";
@@ -0,0 +1,31 @@
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
// window.Pusher = Pusher;
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: import.meta.env.VITE_PUSHER_APP_KEY,
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_CLUSTER}.pusher.com`,
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
// enabledTransports: ['ws', 'wss'],
// });
@@ -0,0 +1,26 @@
const defaultTheme = require("tailwindcss/defaultTheme");
module.exports = {
content: [
"./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php",
"./storage/framework/views/*.php",
"./resources/views/**/*.blade.php",
"./%theme_path%/**/*.{blade.php,js,vue,ts}",
],
theme: {
extend: {
fontFamily: {
sans: ["Nunito", ...defaultTheme.fontFamily.sans],
},
},
},
variants: {
extend: {
opacity: ["disabled"],
},
},
plugins: [require("@tailwindcss/forms")],
};
@@ -0,0 +1,33 @@
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import path from "path";
import tailwindcss from "tailwindcss";
export default defineConfig({
plugins: [
laravel({
input: ["{%theme_path%}/css/app.css", "{%theme_path%}/js/app.js"],
buildDirectory: "%theme_name%",
}),
{
name: "blade",
handleHotUpdate({ file, server }) {
if (file.endsWith(".blade.php")) {
server.ws.send({
type: "full-reload",
path: "*",
});
}
},
},
],
css: {
postcss: {
plugins: [
tailwindcss({
config: path.resolve(__dirname, "tailwind.config.js"),
}),
],
},
},
});
@@ -0,0 +1,20 @@
const mix = require("laravel-mix");
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
mix.setPublicPath("public/themes/%theme%")
.js(`${__dirname}/js/app.js`, "js")
.postCss(`${__dirname}/css/app.css`, "css", [
require("postcss-import"),
require("tailwindcss"),
require("autoprefixer"),
]);
@@ -0,0 +1,38 @@
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import path from "path";
%tailwind_import%
%vue_import%
%react_import%
export default defineConfig({
plugins: [
laravel({
input: [
"%theme_path%%app_css_input%",
"%theme_path%js/app.js"
],
buildDirectory: "%theme_name%",
}),
%vue_plugin_config%
%react_plugin_config%
{
name: "blade",
handleHotUpdate({ file, server }) {
if (file.endsWith(".blade.php")) {
server.ws.send({
type: "full-reload",
path: "*",
});
}
},
},
],
resolve: {
alias: {
'@': '/%theme_path%js',
%bootstrap%
}
},
%css_config%
});
@@ -0,0 +1,23 @@
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Example Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
@@ -0,0 +1,38 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
import "./bootstrap";
/**
* We will create a fresh Vue application instance.
*/
// import { createApp } from "vue";
import { createApp } from "vue/dist/vue.esm-bundler.js";
const app = createApp({});
/**
* The following block of code may be used to automatically register your
* Vue components. It will recursively scan this directory for the Vue
* components and automatically register them with their "basename".
*
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
*/
// const files = import.meta.globEager("./components/*.vue");
// for (const key in files) {
// app.component(key.split("/").pop().split(".")[0], files[key].default);
// }
import ExampleComponent from "./components/ExampleComponent.vue";
app.component("example-component", ExampleComponent);
/**
* Next, attach Vue application instance to the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
app.mount("#app");
@@ -0,0 +1,31 @@
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from "axios";
window.axios = axios;
window.axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
// window.Pusher = Pusher;
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: import.meta.env.VITE_PUSHER_APP_KEY,
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_CLUSTER}.pusher.com`,
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
// enabledTransports: ['ws', 'wss'],
// });
@@ -0,0 +1,14 @@
const mix = require("laravel-mix");
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.login');
}
/**
* Handle an incoming authentication request.
*
* @param LoginRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(route('dashboard', absolute: false));
}
/**
* Destroy an authenticated session.
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function show(Request $request)
{
return view('auth.passwords.confirm');
}
/**
* Confirm the user's password.
*
* @param Request $request
* @return mixed
*/
public function store(Request $request)
{
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,26 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class EmailVerificationNotificationController extends Controller
{
/**
* Send a new email verification notification.
*
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
*
* @param Request $request
* @return mixed
*/
public function __invoke(Request $request)
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(route('dashboard', absolute: false))
: view('auth.verify-email');
}
}
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
*
* @return \Illuminate\View\View
*/
public function create(Request $request)
{
return view('auth.passwords.reset', ['request' => $request]);
}
/**
* Handle an incoming new password request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'token' => 'required',
'email' => 'required|email',
'password' => 'required|string|confirmed|min:8',
]);
// 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)]);
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.passwords.forget');
}
/**
* Handle an incoming password reset link request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$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)]);
}
}
@@ -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\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('auth.register');
}
/**
* Handle an incoming registration request.
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request)
{
$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|confirmed|min:8',
]);
Auth::login($user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]));
event(new Registered($user));
return redirect('dashboard');
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*
* @param EmailVerificationRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function __invoke(EmailVerificationRequest $request)
{
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');
}
}
@@ -0,0 +1,93 @@
<?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.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|string|email',
'password' => 'required|string',
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->filled('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited()
{
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.
*
* @return string
*/
public function throttleKey()
{
return Str::lower($this->input('email')).'|'.$this->ip();
}
}
@@ -0,0 +1,18 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AppLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.app');
}
}
@@ -0,0 +1,18 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class GuestLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('layouts.guest');
}
}
@@ -0,0 +1,71 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="mb-0 form-group row">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,47 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Confirm Password') }}</div>
<div class="card-body">
{{ __('Please confirm your password before continuing.') }}
<form method="POST" action="{{ route('password.confirm') }}">
@csrf
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="mb-0 form-group row">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Confirm Password') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,45 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
<form method="POST" action="{{ route('password.email') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="mb-0 form-group row">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Send Password Reset Link') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,63 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('password.update') }}">
@csrf
<input type="hidden" name="token" value="{{ request()->token }}">
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="mb-0 form-group row">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Reset Password') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,75 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="mb-0 form-group row">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,26 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Verify Your Email Address') }}</div>
<div class="card-body">
@if (session('status') == 'verification-link-sent')
<div class="alert alert-success" role="alert">
{{ __('A fresh verification link has been sent to your email address.') }}
</div>
@endif
{{ __('Before proceeding, please check your email for a verification link.') }}
{{ __('If you did not receive the email') }},
<form class="d-inline" method="POST" action="{{ route('verification.send') }}">
@csrf
<button type="submit" class="p-0 m-0 align-baseline btn btn-link">{{ __('click here to request another') }}</button>.
</form>
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,21 @@
<x-app-layout>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
{{ __('You are logged in!') }}
</div>
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,27 @@
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
%vite%
</head>
<body>
<div id="app">
@include('layouts.navigation')
<main class="py-4">
{{ $slot }}
</main>
</div>
</body>
</html>
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
%vite%
</head>
<body>
<div id="app">
<main class="py-4">
{{ $slot }}
</main>
</div>
</body>
</html>
@@ -0,0 +1,53 @@
<nav class="bg-white shadow-sm navbar navbar-expand-md navbar-light">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="mr-auto navbar-nav">
</ul>
<!-- Right Side Of Navbar -->
<ul class="ml-auto navbar-nav">
<!-- Authentication Links -->
@guest
@if (Route::has('login'))
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
@endif
@if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
@@ -0,0 +1,76 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('login') }}">
@csrf
<!-- Email Address -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Email') }}
</label>
<input id="email" type="email"
class="form-input w-full @error('email') border-red-500 @enderror" name="email"
value="{{ old('email') }}" required autocomplete="email">
@error('email')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Password') }}
</label>
<input id="password" type="password"
class="form-input w-full @error('password') border-red-500 @enderror" name="password"
required autocomplete="new-password">
@error('password')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Remember Me -->
<div class="block mt-4">
<label for="remember_me" class="inline-flex items-center">
<input id="remember_me" type="checkbox" class="text-indigo-600 border-gray-300 rounded shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" name="remember">
<span class="ml-2 text-sm text-gray-600">{{ __('Remember me') }}</span>
</label>
</div>
<div class="flex items-center justify-end mt-4">
@if (Route::has('password.request'))
<a class="text-sm text-gray-600 underline hover:text-gray-900" href="{{ route('password.request') }}">
{{ __('Forgot your password?') }}
</a>
@endif
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Log in') }}
</button>
</div>
</form>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,45 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<div class="mb-4 text-sm text-gray-600">
{{ __('This is a secure area of the application. Please confirm your password before continuing.') }}
</div>
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('password.confirm') }}">
@csrf
<!-- Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Password') }}
</label>
<input id="password" type="password"
class="form-input w-full @error('password') border-red-500 @enderror" name="password"
required autocomplete="new-password">
@error('password')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<div class="flex justify-end mt-4">
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Confirm') }}
</button>
</div>
</form>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,48 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<div class="mb-4 text-sm text-gray-600">
{{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
</div>
<form method="POST" action="{{ route('password.email') }}">
@csrf
<!-- Email Address -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Email') }}
</label>
<input id="email" type="email"
class="form-input w-full @error('email') border-red-500 @enderror" name="email"
value="{{ old('email') }}" required autocomplete="email">
@error('email')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<div class="flex items-center justify-end mt-4">
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Email Password Reset Link') }}
</button>
</div>
</form>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,74 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('password.update') }}">
@csrf
<!-- Password Reset Token -->
<input type="hidden" name="token" value="{{ $request->route('token') }}">
<!-- Email Address -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Email') }}
</label>
<input id="email" type="email"
class="form-input w-full @error('email') border-red-500 @enderror" name="email"
value="{{ old('email', $request->email) }}" required autocomplete="email">
@error('email')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Password') }}
</label>
<input id="password" type="password"
class="form-input w-full @error('password') border-red-500 @enderror" name="password"
required autocomplete="new-password">
@error('password')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Confirm Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Confirm Password') }}
</label>
<input id="password-confirm" type="password" class="w-full form-input"
name="password_confirmation" required autocomplete="new-password">
</div>
<div class="flex items-center justify-end mt-4">
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Reset Password') }}
</button>
</div>
</form>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,90 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('register') }}">
@csrf
<!-- Name -->
<div>
<label class="block text-sm font-medium text-gray-700">
{{ __('Name') }}
</label>
<input id="name" type="text" class="form-input w-full @error('name') border-red-500 @enderror"
name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Email Address -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Email') }}
</label>
<input id="email" type="email"
class="form-input w-full @error('email') border-red-500 @enderror" name="email"
value="{{ old('email') }}" required autocomplete="email">
@error('email')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Password') }}
</label>
<input id="password" type="password"
class="form-input w-full @error('password') border-red-500 @enderror" name="password"
required autocomplete="new-password">
@error('password')
<p class="mt-1 text-xs italic text-red-500">
{{ $message }}
</p>
@enderror
</div>
<!-- Confirm Password -->
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700">
{{ __('Confirm Password') }}
</label>
<input id="password-confirm" type="password" class="w-full form-input"
name="password_confirmation" required autocomplete="new-password">
</div>
<div class="flex items-center justify-end mt-4">
<a class="text-sm text-gray-600 underline hover:text-gray-900" href="{{ route('login') }}">
{{ __('Already registered?') }}
</a>
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Register') }}
</button>
</div>
</form>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,41 @@
<x-guest-layout>
<div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0">
<div>
<a href="/">
<x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
</a>
</div>
<div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md sm:rounded-lg">
<div class="mb-4 text-sm text-gray-600">
{{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }}
</div>
@if (session('status') == 'verification-link-sent')
<div class="mb-4 text-sm font-medium text-green-600">
{{ __('A new verification link has been sent to the email address you provided during registration.') }}
</div>
@endif
<div class="flex items-center justify-between mt-4">
<form method="POST" action="{{ route('verification.send') }}">
@csrf
<div>
<button type="submit" class="inline-flex items-center px-4 py-2 ml-4 text-xs font-semibold tracking-widest text-white uppercase transition duration-150 ease-in-out bg-gray-800 border border-transparent rounded-md hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25">
{{ __('Resend Verification Email') }}
</button>
</div>
</form>
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit" class="text-sm text-gray-600 underline hover:text-gray-900">
{{ __('Log Out') }}
</button>
</form>
</div>
</div>
</div>
</x-guest-layout>
@@ -0,0 +1,3 @@
<svg viewBox="0 0 316 316" xmlns="http://www.w3.org/2000/svg" {{ $attributes }}>
<path d="M305.8 81.125C305.77 80.995 305.69 80.885 305.65 80.755C305.56 80.525 305.49 80.285 305.37 80.075C305.29 79.935 305.17 79.815 305.07 79.685C304.94 79.515 304.83 79.325 304.68 79.175C304.55 79.045 304.39 78.955 304.25 78.845C304.09 78.715 303.95 78.575 303.77 78.475L251.32 48.275C249.97 47.495 248.31 47.495 246.96 48.275L194.51 78.475C194.33 78.575 194.19 78.725 194.03 78.845C193.89 78.955 193.73 79.045 193.6 79.175C193.45 79.325 193.34 79.515 193.21 79.685C193.11 79.815 192.99 79.935 192.91 80.075C192.79 80.285 192.71 80.525 192.63 80.755C192.58 80.875 192.51 80.995 192.48 81.125C192.38 81.495 192.33 81.875 192.33 82.265V139.625L148.62 164.795V52.575C148.62 52.185 148.57 51.805 148.47 51.435C148.44 51.305 148.36 51.195 148.32 51.065C148.23 50.835 148.16 50.595 148.04 50.385C147.96 50.245 147.84 50.125 147.74 49.995C147.61 49.825 147.5 49.635 147.35 49.485C147.22 49.355 147.06 49.265 146.92 49.155C146.76 49.025 146.62 48.885 146.44 48.785L93.99 18.585C92.64 17.805 90.98 17.805 89.63 18.585L37.18 48.785C37 48.885 36.86 49.035 36.7 49.155C36.56 49.265 36.4 49.355 36.27 49.485C36.12 49.635 36.01 49.825 35.88 49.995C35.78 50.125 35.66 50.245 35.58 50.385C35.46 50.595 35.38 50.835 35.3 51.065C35.25 51.185 35.18 51.305 35.15 51.435C35.05 51.805 35 52.185 35 52.575V232.235C35 233.795 35.84 235.245 37.19 236.025L142.1 296.425C142.33 296.555 142.58 296.635 142.82 296.725C142.93 296.765 143.04 296.835 143.16 296.865C143.53 296.965 143.9 297.015 144.28 297.015C144.66 297.015 145.03 296.965 145.4 296.865C145.5 296.835 145.59 296.775 145.69 296.745C145.95 296.655 146.21 296.565 146.45 296.435L251.36 236.035C252.72 235.255 253.55 233.815 253.55 232.245V174.885L303.81 145.945C305.17 145.165 306 143.725 306 142.155V82.265C305.95 81.875 305.89 81.495 305.8 81.125ZM144.2 227.205L100.57 202.515L146.39 176.135L196.66 147.195L240.33 172.335L208.29 190.625L144.2 227.205ZM244.75 114.995V164.795L226.39 154.225L201.03 139.625V89.825L219.39 100.395L244.75 114.995ZM249.12 57.105L292.81 82.265L249.12 107.425L205.43 82.265L249.12 57.105ZM114.49 184.425L96.13 194.995V85.305L121.49 70.705L139.85 60.135V169.815L114.49 184.425ZM91.76 27.425L135.45 52.585L91.76 77.745L48.07 52.585L91.76 27.425ZM43.67 60.135L62.03 70.705L87.39 85.305V202.545V202.555V202.565C87.39 202.735 87.44 202.895 87.46 203.055C87.49 203.265 87.49 203.485 87.55 203.695V203.705C87.6 203.875 87.69 204.035 87.76 204.195C87.84 204.375 87.89 204.575 87.99 204.745C87.99 204.745 87.99 204.755 88 204.755C88.09 204.905 88.22 205.035 88.33 205.175C88.45 205.335 88.55 205.495 88.69 205.635L88.7 205.645C88.82 205.765 88.98 205.855 89.12 205.965C89.28 206.085 89.42 206.225 89.59 206.325C89.6 206.325 89.6 206.325 89.61 206.335C89.62 206.335 89.62 206.345 89.63 206.345L139.87 234.775V285.065L43.67 229.705V60.135ZM244.75 229.705L148.58 285.075V234.775L219.8 194.115L244.75 179.875V229.705ZM297.2 139.625L253.49 164.795V114.995L278.85 100.395L297.21 89.825V139.625H297.2Z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

@@ -0,0 +1,7 @@
@props(['status'])
@if ($status)
<div {{ $attributes->merge(['class' => 'font-medium text-sm text-green-600']) }}>
{{ $status }}
</div>
@endif
@@ -0,0 +1,15 @@
@props(['errors'])
@if ($errors->any())
<div {{ $attributes }}>
<div class="font-medium text-red-600">
{{ __('Whoops! Something went wrong.') }}
</div>
<ul class="mt-3 text-sm text-red-600 list-disc list-inside">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@@ -0,0 +1,17 @@
<x-app-layout>
<x-slot name="header">
<h2 class="text-xl font-semibold leading-tight text-gray-800">
{{ __('Dashboard') }}
</h2>
</x-slot>
<div class="py-12">
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
<div class="overflow-hidden bg-white shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
You're logged in!
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
%vite%
</head>
<body class="font-sans antialiased">
<div id="app" class="min-h-screen bg-gray-100">
@include('layouts.navigation')
<!-- Page Heading -->
<header class="bg-white shadow">
<div class="px-4 py-6 mx-auto max-w-7xl sm:px-6 lg:px-8">
{{ $header }}
</div>
</header>
<!-- Page Content -->
<main>
{{ $slot }}
</main>
</div>
</body>
</html>
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
%vite%
</head>
<body>
<div id="app" class="font-sans antialiased text-gray-900">
{{ $slot }}
</div>
</body>
</html>
@@ -0,0 +1,40 @@
<nav class="bg-white border-b border-gray-100">
<!-- Primary Navigation Menu -->
<div class="px-4 mx-auto max-w-7xl sm:px-6 lg:px-8">
<div class="flex justify-between h-16 text-gray-500 hover:text-gray-700 text-sm font-medium leading-5">
<div class="flex">
<!-- Logo -->
<div class="flex items-center flex-shrink-0">
<a href="{{ route('dashboard') }}">
<x-application-logo class="block w-auto h-10 text-gray-600 fill-current" />
</a>
</div>
<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
<a href="{{ route('dashboard') }}"
class="{{ request()->routeIs('dashboard') ? 'border-indigo-400 text-gray-900 focus:border-indigo-700' : 'border-transparent hover:border-gray-300 focus:text-gray-700 focus:border-gray-300' }} inline-flex items-center px-1 pt-1 border-b-2 focus:outline-none">
{{ __('Dashboard') }}
</a>
</div>
</div>
<!-- Settings -->
<div class="hidden sm:flex sm:items-center sm:ml-6">
@auth
<div>{{ Auth::user()->name }}</div>
<a href="{{ route('logout') }}"
class="h-16 ml-4 border-transparent hover:border-gray-300 focus:text-gray-700 focus:border-gray-300 inline-flex items-center px-1 pt-1 border-b-2 focus:outline-none"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="hidden">
@csrf
</form>
@endauth
</div>
</div>
</div>
</nav>
@@ -0,0 +1,64 @@
<?php
use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\ConfirmablePasswordController;
use App\Http\Controllers\Auth\EmailVerificationNotificationController;
use App\Http\Controllers\Auth\EmailVerificationPromptController;
use App\Http\Controllers\Auth\NewPasswordController;
use App\Http\Controllers\Auth\PasswordResetLinkController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\VerifyEmailController;
use Illuminate\Support\Facades\Route;
Route::get('/register', [RegisteredUserController::class, 'create'])
->middleware('guest')
->name('register');
Route::post('/register', [RegisteredUserController::class, 'store'])
->middleware('guest');
Route::get('/login', [AuthenticatedSessionController::class, 'create'])
->middleware('guest')
->name('login');
Route::post('/login', [AuthenticatedSessionController::class, 'store'])
->middleware('guest');
Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])
->middleware('guest')
->name('password.request');
Route::post('/forgot-password', [PasswordResetLinkController::class, 'store'])
->middleware('guest')
->name('password.email');
Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])
->middleware('guest')
->name('password.reset');
Route::post('/reset-password', [NewPasswordController::class, 'store'])
->middleware('guest')
->name('password.update');
Route::get('/verify-email', [EmailVerificationPromptController::class, '__invoke'])
->middleware('auth')
->name('verification.notice');
Route::get('/verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke'])
->middleware(['auth', 'signed', 'throttle:6,1'])
->name('verification.verify');
Route::post('/email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
->middleware(['auth', 'throttle:6,1'])
->name('verification.send');
Route::get('/confirm-password', [ConfirmablePasswordController::class, 'show'])
->middleware('auth')
->name('password.confirm');
Route::post('/confirm-password', [ConfirmablePasswordController::class, 'store'])
->middleware('auth');
Route::post('/logout', [AuthenticatedSessionController::class, 'destroy'])
->middleware('auth')
->name('logout');
@@ -0,0 +1,44 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AuthenticationTest extends TestCase
{
use RefreshDatabase;
public function test_login_screen_can_be_rendered()
{
$response = $this->get('/login');
$response->assertStatus(200);
}
public function test_users_can_authenticate_using_the_login_screen()
{
$user = User::factory()->create();
$response = $this->post('/login', [
'email' => $user->email,
'password' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
}
public function test_users_can_not_authenticate_with_invalid_password()
{
$user = User::factory()->create();
$this->post('/login', [
'email' => $user->email,
'password' => 'wrong-password',
]);
$this->assertGuest();
}
}
@@ -0,0 +1,64 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;
class EmailVerificationTest extends TestCase
{
use RefreshDatabase;
public function test_email_verification_screen_can_be_rendered()
{
$user = User::factory()->create([
'email_verified_at' => null,
]);
$response = $this->actingAs($user)->get('/verify-email');
$response->assertStatus(200);
}
public function test_email_can_be_verified()
{
Event::fake();
$user = User::factory()->create([
'email_verified_at' => null,
]);
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1($user->email)]
);
$response = $this->actingAs($user)->get($verificationUrl);
Event::assertDispatched(Verified::class);
$this->assertTrue($user->fresh()->hasVerifiedEmail());
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
}
public function test_email_is_not_verified_with_invalid_hash()
{
$user = User::factory()->create([
'email_verified_at' => null,
]);
$verificationUrl = URL::temporarySignedRoute(
'verification.verify',
now()->addMinutes(60),
['id' => $user->id, 'hash' => sha1('wrong-email')]
);
$this->actingAs($user)->get($verificationUrl);
$this->assertFalse($user->fresh()->hasVerifiedEmail());
}
}
@@ -0,0 +1,44 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PasswordConfirmationTest extends TestCase
{
use RefreshDatabase;
public function test_confirm_password_screen_can_be_rendered()
{
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/confirm-password');
$response->assertStatus(200);
}
public function test_password_can_be_confirmed()
{
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/confirm-password', [
'password' => 'password',
]);
$response->assertRedirect();
$response->assertSessionHasNoErrors();
}
public function test_password_is_not_confirmed_with_invalid_password()
{
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/confirm-password', [
'password' => 'wrong-password',
]);
$response->assertSessionHasErrors();
}
}
@@ -0,0 +1,71 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class PasswordResetTest extends TestCase
{
use RefreshDatabase;
public function test_reset_password_link_screen_can_be_rendered()
{
$response = $this->get('/forgot-password');
$response->assertStatus(200);
}
public function test_reset_password_link_can_be_requested()
{
Notification::fake();
$user = User::factory()->create();
$this->post('/forgot-password', ['email' => $user->email]);
Notification::assertSentTo($user, ResetPassword::class);
}
public function test_reset_password_screen_can_be_rendered()
{
Notification::fake();
$user = User::factory()->create();
$this->post('/forgot-password', ['email' => $user->email]);
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
$response = $this->get('/reset-password/'.$notification->token);
$response->assertStatus(200);
return true;
});
}
public function test_password_can_be_reset_with_valid_token()
{
Notification::fake();
$user = User::factory()->create();
$this->post('/forgot-password', ['email' => $user->email]);
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
$response = $this->post('/reset-password', [
'token' => $notification->token,
'email' => $user->email,
'password' => 'password',
'password_confirmation' => 'password',
]);
$response->assertSessionHasNoErrors();
return true;
});
}
}
@@ -0,0 +1,31 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class RegistrationTest extends TestCase
{
use RefreshDatabase;
public function test_registration_screen_can_be_rendered()
{
$response = $this->get('/register');
$response->assertStatus(200);
}
public function test_new_users_can_register()
{
$response = $this->post('/register', [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'password',
'password_confirmation' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
}
}