Primo commit dal server Linux: progetto funzionante e aggiornato
This commit is contained in:
parent
24992624f0
commit
b8b305fc79
18
.editorconfig
Normal file
18
.editorconfig
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
||||||
65
.env.example
Normal file
65
.env.example
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=mdb_archivio
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
.styleci.yml export-ignore
|
||||||
31
.gitignore
vendored
31
.gitignore
vendored
|
|
@ -1 +1,30 @@
|
||||||
node_modules
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.nova
|
||||||
|
/.phpunit.cache
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
||||||
|
/auth.json
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/app/public
|
||||||
|
/storage/framework
|
||||||
|
/storage/logs
|
||||||
|
/venv
|
||||||
|
/vendor
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
Thumbs.db
|
||||||
|
yarn-error.log
|
||||||
|
|
||||||
|
|
|
||||||
44
Dockerfile
Normal file
44
Dockerfile
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
FROM php:8.2-fpm
|
||||||
|
|
||||||
|
# Installa dipendenze di sistema
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
nodejs \
|
||||||
|
npm
|
||||||
|
|
||||||
|
# Pulisce cache
|
||||||
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Installa estensioni PHP
|
||||||
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
|
||||||
|
|
||||||
|
# Installa Composer
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Imposta directory di lavoro
|
||||||
|
WORKDIR /var/www
|
||||||
|
|
||||||
|
# Copia file applicazione
|
||||||
|
COPY . /var/www
|
||||||
|
|
||||||
|
# Installa dipendenze PHP
|
||||||
|
RUN composer install --optimize-autoloader --no-dev
|
||||||
|
|
||||||
|
# Installa dipendenze Node.js
|
||||||
|
RUN npm install && npm run build
|
||||||
|
|
||||||
|
# Imposta permessi
|
||||||
|
RUN chown -R www-data:www-data /var/www \
|
||||||
|
&& chmod -R 755 /var/www/storage \
|
||||||
|
&& chmod -R 755 /var/www/bootstrap/cache
|
||||||
|
|
||||||
|
# Espone porta 9000
|
||||||
|
EXPOSE 9000
|
||||||
|
|
||||||
|
CMD ["php-fpm"]
|
||||||
63
README.md
63
README.md
|
|
@ -1,3 +1,62 @@
|
||||||
# sb1-netgescon
|
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## About Laravel
|
||||||
|
|
||||||
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
|
|
||||||
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
|
## Learning Laravel
|
||||||
|
|
||||||
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||||
|
|
||||||
|
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
|
## Laravel Sponsors
|
||||||
|
|
||||||
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||||
|
|
||||||
|
### Premium Partners
|
||||||
|
|
||||||
|
- **[Vehikl](https://vehikl.com)**
|
||||||
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||||
|
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||||
|
- **[Redberry](https://redberry.international/laravel-development)**
|
||||||
|
- **[Active Logic](https://activelogic.com)**
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
|
|
||||||
[Edit in StackBlitz next generation editor ⚡️](https://stackblitz.com/~/github.com/Pikappa2/sb1-netgescon)
|
|
||||||
52
app/Http/Controllers/Admin/ApiTokenController.php
Normal file
52
app/Http/Controllers/Admin/ApiTokenController.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ApiTokenController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('permission:manage-api-tokens');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
// Laravel Sanctum non fornisce un modo diretto per listare i token senza Jetstream/Fortify UI.
|
||||||
|
// Solitamente si mostra un form per creare un nuovo token e si visualizza il token *solo una volta* dopo la creazione.
|
||||||
|
// L'utente deve copiarlo e salvarlo.
|
||||||
|
// Si possono elencare i token esistenti (senza mostrare il valore plain-text) per permetterne la revoca.
|
||||||
|
$tokens = $user->tokens; // Collection di PersonalAccessToken
|
||||||
|
|
||||||
|
return view('admin.api-tokens.index', ['tokens' => $tokens]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token_name' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
$tokenName = $request->input('token_name');
|
||||||
|
|
||||||
|
// Puoi definire delle 'abilities' (permessi) per il token se necessario
|
||||||
|
// $newToken = $user->createToken($tokenName, ['import:data']);
|
||||||
|
$newToken = $user->createToken($tokenName);
|
||||||
|
|
||||||
|
// IMPORTANTE: Il plainTextToken è visibile solo qui, subito dopo la creazione.
|
||||||
|
// Dovrai passarlo alla vista e informare l'utente di copiarlo immediatamente.
|
||||||
|
return back()->with('status', 'Token API creato con successo! Copia il token: ' . $newToken->plainTextToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, $tokenId)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$user->tokens()->where('id', $tokenId)->delete();
|
||||||
|
return back()->with('status', 'Token API revocato con successo.');
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Controllers/Admin/ImpostazioniController.php
Normal file
19
app/Http/Controllers/Admin/ImpostazioniController.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ImpostazioniController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('permission:view-impostazioni');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('admin.impostazioni.index');
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Http/Controllers/Admin/RubricaController.php
Normal file
40
app/Http/Controllers/Admin/RubricaController.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Soggetto;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RubricaController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('permission:view-rubrica');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
// Per la rubrica globale, l'amministratore dovrebbe vedere tutte le anagrafiche
|
||||||
|
// a cui ha accesso tramite i suoi condomini.
|
||||||
|
// Per semplicità iniziale, mostriamo tutte le anagrafiche.
|
||||||
|
// In futuro, si potrebbe filtrare per anagrafiche associate a unità immobiliari
|
||||||
|
// dei condomini gestiti dall'amministratore corrente.
|
||||||
|
|
||||||
|
$query = Soggetto::query(); // La relazione con unità e stabili può essere caricata se necessario
|
||||||
|
|
||||||
|
if ($request->filled('search')) {
|
||||||
|
$search = $request->input('search');
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('nome', 'like', "%{$search}%")
|
||||||
|
->orWhere('cognome', 'like', "%{$search}%")
|
||||||
|
->orWhere('ragione_sociale', 'like', "%{$search}%")
|
||||||
|
->orWhere('email', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$soggetti = $query->orderBy('ragione_sociale')->orderBy('cognome')->orderBy('nome')->paginate(20);
|
||||||
|
return view('admin.rubrica.index', compact('soggetti'));
|
||||||
|
}
|
||||||
|
}
|
||||||
123
app/Http/Controllers/Admin/SoggettoController.php
Normal file
123
app/Http/Controllers/Admin/SoggettoController.php
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Soggetto;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate; // Aggiunto per Gate
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class SoggettoController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Proteggi le rotte con permessi specifici per l'Admin
|
||||||
|
$this->middleware('permission:view-soggetti', ['only' => ['index', 'show']]);
|
||||||
|
$this->middleware('permission:manage-soggetti', ['except' => ['index', 'show']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
Gate::authorize('view-soggetti'); // Verifica permesso specifico
|
||||||
|
$soggetti = Soggetto::paginate(10);
|
||||||
|
return view('admin.soggetti.index', compact('soggetti'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
Gate::authorize('manage-soggetti'); // Verifica permesso specifico
|
||||||
|
$tipi_anagrafica = ['proprietario', 'inquilino', 'usufruttuario', 'altro'];
|
||||||
|
return view('admin.soggetti.create', compact('tipi_anagrafica'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
Gate::authorize('manage-soggetti'); // Verifica permesso specifico
|
||||||
|
$request->validate([
|
||||||
|
'nome' => 'nullable|string|max:255',
|
||||||
|
'cognome' => 'nullable|string|max:255',
|
||||||
|
'ragione_sociale' => 'nullable|string|max:255',
|
||||||
|
'codice_fiscale' => 'nullable|string|max:16|unique:soggetti,codice_fiscale',
|
||||||
|
'partita_iva' => 'nullable|string|max:11|unique:soggetti,partita_iva',
|
||||||
|
'email' => 'nullable|email|max:255|unique:soggetti,email',
|
||||||
|
'telefono' => 'nullable|string|max:20',
|
||||||
|
'indirizzo' => 'nullable|string|max:255',
|
||||||
|
'cap' => 'nullable|string|max:10',
|
||||||
|
'citta' => 'nullable|string|max:60',
|
||||||
|
'provincia' => 'nullable|string|max:2',
|
||||||
|
'tipo' => 'required|in:proprietario,inquilino,usufruttuario,altro',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Soggetto::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('admin.soggetti.index')->with('success', 'Soggetto creato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Soggetto $soggetto)
|
||||||
|
{
|
||||||
|
Gate::authorize('view-soggetti'); // Verifica permesso specifico
|
||||||
|
return view('admin.soggetti.show', compact('soggetto'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Soggetto $soggetto)
|
||||||
|
{
|
||||||
|
Gate::authorize('manage-soggetti'); // Verifica permesso specifico
|
||||||
|
$tipi_anagrafica = ['proprietario', 'inquilino', 'usufruttuario', 'altro'];
|
||||||
|
return view('admin.soggetti.edit', compact('soggetto', 'tipi_anagrafica'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Soggetto $soggetto)
|
||||||
|
{
|
||||||
|
Gate::authorize('manage-soggetti'); // Verifica permesso specifico
|
||||||
|
$request->validate([
|
||||||
|
'nome' => 'nullable|string|max:255',
|
||||||
|
'cognome' => 'nullable|string|max:255',
|
||||||
|
'ragione_sociale' => 'nullable|string|max:255',
|
||||||
|
'codice_fiscale' => ['nullable', 'string', 'max:16', Rule::unique('soggetti', 'codice_fiscale')->ignore($soggetto->id_soggetto, 'id_soggetto')],
|
||||||
|
'partita_iva' => ['nullable', 'string', 'max:11', Rule::unique('soggetti', 'partita_iva')->ignore($soggetto->id_soggetto, 'id_soggetto')],
|
||||||
|
'email' => ['nullable', 'email', 'max:255', Rule::unique('soggetti', 'email')->ignore($soggetto->id_soggetto, 'id_soggetto')],
|
||||||
|
'telefono' => 'nullable|string|max:20',
|
||||||
|
'indirizzo' => 'nullable|string|max:255',
|
||||||
|
'cap' => 'nullable|string|max:10',
|
||||||
|
'citta' => 'nullable|string|max:60',
|
||||||
|
'provincia' => 'nullable|string|max:2',
|
||||||
|
'tipo' => 'required|in:proprietario,inquilino,usufruttuario,altro',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$soggetto->update($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('admin.soggetti.index')->with('success', 'Soggetto aggiornato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Soggetto $soggetto)
|
||||||
|
{
|
||||||
|
Gate::authorize('manage-soggetti'); // Verifica permesso specifico
|
||||||
|
$soggetto->delete();
|
||||||
|
return redirect()->route('admin.soggetti.index')->with('success', 'Soggetto eliminato con successo.');
|
||||||
|
}
|
||||||
|
}
|
||||||
148
app/Http/Controllers/Api/ImportController.php
Normal file
148
app/Http/Controllers/Api/ImportController.php
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Condominio;
|
||||||
|
use App\Models\Fornitore; // Aggiungi questo
|
||||||
|
use App\Models\UnitaImmobiliare; // Aggiungi questo
|
||||||
|
use App\Models\Anagrafica; // Aggiungi questo
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ImportController extends Controller
|
||||||
|
{
|
||||||
|
// Funzione per importare i condomini (invariata)
|
||||||
|
public function importCondominio(Request $request)
|
||||||
|
{
|
||||||
|
// ... (codice esistente e funzionante)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NUOVA FUNZIONE: Importa o aggiorna un singolo fornitore.
|
||||||
|
*/
|
||||||
|
public function importFornitore(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
if ($user->role !== 'amministratore' || !$user->amministratore()->exists()) {
|
||||||
|
return response()->json(['message' => 'Non autorizzato'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datiValidati = $request->validate([
|
||||||
|
'id_fornitore' => ['required', 'integer'],
|
||||||
|
'cognome' => ['nullable', 'string', 'max:100'],
|
||||||
|
'nome' => ['nullable', 'string', 'max:100'],
|
||||||
|
'indirizzo' => ['nullable', 'string', 'max:255'],
|
||||||
|
'cap' => ['nullable', 'string', 'max:10'],
|
||||||
|
'citta' => ['nullable', 'string', 'max:60'], // Corretto da 'citt' a 'citta'
|
||||||
|
'pr' => ['nullable', 'string', 'max:2'],
|
||||||
|
'p_iva' => ['nullable', 'string', 'max:20'],
|
||||||
|
'cod_fisc' => ['nullable', 'string', 'max:20'],
|
||||||
|
'Indir_Email' => ['nullable', 'email', 'max:100'],
|
||||||
|
'Cellulare' => ['nullable', 'string', 'max:30'],
|
||||||
|
'PEC_Fornitore' => ['nullable', 'email', 'max:100'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$fornitore = Fornitore::updateOrCreate(
|
||||||
|
[
|
||||||
|
'old_id' => $datiValidati['id_fornitore'],
|
||||||
|
'amministratore_id' => $user->amministratore->id // Assicurati che l'utente abbia un amministratore associato
|
||||||
|
],
|
||||||
|
[
|
||||||
|
// 'amministratore_id' => $user->amministratore->id, // Già nel primo array per la ricerca
|
||||||
|
'ragione_sociale' => $datiValidati['cognome'] . ' ' . $datiValidati['nome'],
|
||||||
|
'partita_iva' => $datiValidati['p_iva'],
|
||||||
|
'codice_fiscale' => $datiValidati['cod_fisc'],
|
||||||
|
'email' => $datiValidati['Indir_Email'],
|
||||||
|
'indirizzo' => $datiValidati['indirizzo'],
|
||||||
|
'cap' => $datiValidati['cap'],
|
||||||
|
'citta' => $datiValidati['citta'],
|
||||||
|
'provincia' => $datiValidati['pr'],
|
||||||
|
'telefono' => $datiValidati['Cellulare'],
|
||||||
|
'pec' => $datiValidati['PEC_Fornitore'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Fornitore importato/aggiornato con successo.', 'data' => $fornitore]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NUOVA FUNZIONE: Importa o aggiorna una singola anagrafica (condomino/inquilino).
|
||||||
|
*/
|
||||||
|
public function importAnagrafica(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
if ($user->role !== 'amministratore' || !$user->amministratore()->exists()) {
|
||||||
|
return response()->json(['message' => 'Non autorizzato'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datiValidati = $request->validate([
|
||||||
|
'id_cond' => ['required', 'integer'], // ID anagrafica vecchio gestionale
|
||||||
|
'nom_cond' => ['required', 'string', 'max:150'], // Nome/Cognome o Ragione Sociale
|
||||||
|
'ind' => ['nullable', 'string', 'max:255'],
|
||||||
|
'cap' => ['nullable', 'string', 'max:10'],
|
||||||
|
'citta' => ['nullable', 'string', 'max:60'],
|
||||||
|
'pr' => ['nullable', 'string', 'max:2'],
|
||||||
|
'E_mail_condomino' => ['nullable', 'email', 'max:100'],
|
||||||
|
// 'E_mail_inquilino' => ['nullable', 'email', 'max:100'], // Se necessario
|
||||||
|
'id_stabile' => ['required', 'integer'], // ID stabile vecchio gestionale per trovare il Condominio
|
||||||
|
'scala' => ['nullable', 'string', 'max:10'],
|
||||||
|
'int' => ['nullable', 'string', 'max:10'], // Interno
|
||||||
|
'tipo_pr' => ['nullable', 'string', 'max:4'], // Es. PR, IN per mappare a 'proprietario', 'inquilino'
|
||||||
|
// Aggiungere altri campi se necessari (cod_fisc, p_iva, telefono)
|
||||||
|
// 'cod_fisc' => ['nullable', 'string', 'max:20'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Troviamo il condominio corrispondente nel nostro nuovo sistema
|
||||||
|
$condominio = Condominio::where('old_id', $datiValidati['id_stabile'])
|
||||||
|
->where('amministratore_id', $user->amministratore->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$condominio) {
|
||||||
|
return response()->json(['message' => 'Condominio (stabile) non trovato con old_id: ' . $datiValidati['id_stabile']], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mappatura tipo_pr a tipo anagrafica
|
||||||
|
$tipoAnagrafica = 'proprietario'; // Default
|
||||||
|
if (isset($datiValidati['tipo_pr'])) {
|
||||||
|
if (strtoupper($datiValidati['tipo_pr']) === 'IN') {
|
||||||
|
$tipoAnagrafica = 'inquilino';
|
||||||
|
}
|
||||||
|
// Aggiungere altre mappature se necessario (es. usufruttuario)
|
||||||
|
}
|
||||||
|
|
||||||
|
$anagrafica = Anagrafica::updateOrCreate(
|
||||||
|
['old_id' => $datiValidati['id_cond']],
|
||||||
|
[
|
||||||
|
'ragione_sociale' => $datiValidati['nom_cond'],
|
||||||
|
'email' => $datiValidati['E_mail_condomino'],
|
||||||
|
'indirizzo' => $datiValidati['ind'],
|
||||||
|
'cap' => $datiValidati['cap'],
|
||||||
|
'citta' => $datiValidati['citta'],
|
||||||
|
'provincia' => $datiValidati['pr'],
|
||||||
|
'tipo' => $tipoAnagrafica,
|
||||||
|
// Aggiungere altri campi mappati qui
|
||||||
|
// 'codice_fiscale' => $datiValidati['cod_fisc'],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Logica per trovare/creare e associare l'UnitaImmobiliare
|
||||||
|
$unitaImmobiliare = null;
|
||||||
|
if ($datiValidati['scala'] || $datiValidati['int']) {
|
||||||
|
$unitaImmobiliare = UnitaImmobiliare::firstOrCreate(
|
||||||
|
[
|
||||||
|
'condominio_id' => $condominio->id,
|
||||||
|
'scala' => $datiValidati['scala'],
|
||||||
|
'interno' => $datiValidati['int'],
|
||||||
|
]
|
||||||
|
// Eventualmente aggiungere altri campi se necessari per l'unità
|
||||||
|
);
|
||||||
|
|
||||||
|
// Associa anagrafica a unità immobiliare (se non già associata)
|
||||||
|
// La tabella pivot ha una chiave primaria composta, quindi attach non duplicherà
|
||||||
|
$anagrafica->unitaImmobiliari()->syncWithoutDetaching([$unitaImmobiliare->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Anagrafica importata/aggiornata con successo.', 'data' => $anagrafica, 'unita_associata' => $unitaImmobiliare]);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
47
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Auth\LoginRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AuthenticatedSessionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the login view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming authentication request.
|
||||||
|
*/
|
||||||
|
public function store(LoginRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->authenticate();
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy an authenticated session.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
Auth::guard('web')->logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
40
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ConfirmablePasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the confirm password view.
|
||||||
|
*/
|
||||||
|
public function show(): View
|
||||||
|
{
|
||||||
|
return view('auth.confirm-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm the user's password.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if (! Auth::guard('web')->validate([
|
||||||
|
'email' => $request->user()->email,
|
||||||
|
'password' => $request->password,
|
||||||
|
])) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'password' => __('auth.password'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->session()->put('auth.password_confirmed_at', time());
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class EmailVerificationNotificationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Send a new email verification notification.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->sendEmailVerificationNotification();
|
||||||
|
|
||||||
|
return back()->with('status', 'verification-link-sent');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class EmailVerificationPromptController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the email verification prompt.
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request): RedirectResponse|View
|
||||||
|
{
|
||||||
|
return $request->user()->hasVerifiedEmail()
|
||||||
|
? redirect()->intended(route('dashboard', absolute: false))
|
||||||
|
: view('auth.verify-email');
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
62
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class NewPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset view.
|
||||||
|
*/
|
||||||
|
public function create(Request $request): View
|
||||||
|
{
|
||||||
|
return view('auth.reset-password', ['request' => $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming new password request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token' => ['required'],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Here we will attempt to reset the user's password. If it is successful we
|
||||||
|
// will update the password on an actual user model and persist it to the
|
||||||
|
// database. Otherwise we will parse the error and return the response.
|
||||||
|
$status = Password::reset(
|
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||||
|
function (User $user) use ($request) {
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'remember_token' => Str::random(60),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
event(new PasswordReset($user));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the password was successfully reset, we will redirect the user back to
|
||||||
|
// the application's home authenticated view. If there is an error we can
|
||||||
|
// redirect them back to where they came from with their error message.
|
||||||
|
return $status == Password::PASSWORD_RESET
|
||||||
|
? redirect()->route('login')->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
|
class PasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Update the user's password.
|
||||||
|
*/
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validateWithBag('updatePassword', [
|
||||||
|
'current_password' => ['required', 'current_password'],
|
||||||
|
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->user()->update([
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('status', 'password-updated');
|
||||||
|
}
|
||||||
|
}
|
||||||
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class PasswordResetLinkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset link request view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.forgot-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming password reset link request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// We will send the password reset link to this user. Once we have attempted
|
||||||
|
// to send the link, we will examine the response then see the message we
|
||||||
|
// need to show to the user. Finally, we'll send out a proper response.
|
||||||
|
$status = Password::sendResetLink(
|
||||||
|
$request->only('email')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $status == Password::RESET_LINK_SENT
|
||||||
|
? back()->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
50
app/Http/Controllers/Auth/RegisteredUserController.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class RegisteredUserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the registration view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming registration request.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
event(new Registered($user));
|
||||||
|
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
return redirect(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
27
app/Http/Controllers/Auth/VerifyEmailController.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Auth\Events\Verified;
|
||||||
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class VerifyEmailController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Mark the authenticated user's email address as verified.
|
||||||
|
*/
|
||||||
|
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->user()->markEmailAsVerified()) {
|
||||||
|
event(new Verified($request->user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
103
app/Http/Controllers/CondominioController.php
Normal file
103
app/Http/Controllers/CondominioController.php
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Condominio;
|
||||||
|
use App\Models\Amministratore;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CondominioController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Proteggi le rotte con i permessi di Spatie
|
||||||
|
$this->middleware('permission:view-condomini', ['only' => ['index', 'show']]);
|
||||||
|
$this->middleware('permission:create-condomini', ['only' => ['create', 'store']]);
|
||||||
|
$this->middleware('permission:edit-condomini', ['only' => ['edit', 'update']]);
|
||||||
|
$this->middleware('permission:delete-condomini', ['only' => ['destroy']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$condomini = Condominio::with('amministratore.user')->paginate(10);
|
||||||
|
return view('condomini.index', compact('condomini'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$amministratori = Amministratore::all(); // Per la dropdown
|
||||||
|
return view('condomini.create', compact('amministratori'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request) // Qui useremo un FormRequest in futuro
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'denominazione' => 'required|string|max:255',
|
||||||
|
'id_amministratore' => 'required|exists:amministratori,id_amministratore',
|
||||||
|
'indirizzo' => 'required|string|max:255',
|
||||||
|
'cap' => 'required|string|max:5',
|
||||||
|
'citta' => 'required|string|max:255',
|
||||||
|
'provincia' => 'required|string|max:2',
|
||||||
|
'codice_fiscale' => 'nullable|string|max:16|unique:condomini,codice_fiscale',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Condominio::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('condomini.index')->with('success', 'Condominio creato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Condominio $condominio)
|
||||||
|
{
|
||||||
|
return view('condomini.show', compact('condominio'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Condominio $condominio)
|
||||||
|
{
|
||||||
|
$amministratori = Amministratore::all();
|
||||||
|
return view('condomini.edit', compact('condominio', 'amministratori'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Condominio $condominio) // Qui useremo un FormRequest in futuro
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'denominazione' => 'required|string|max:255',
|
||||||
|
'id_amministratore' => 'required|exists:amministratori,id_amministratore',
|
||||||
|
'indirizzo' => 'required|string|max:255',
|
||||||
|
'cap' => 'required|string|max:5',
|
||||||
|
'citta' => 'required|string|max:255',
|
||||||
|
'provincia' => 'required|string|max:2',
|
||||||
|
'codice_fiscale' => 'nullable|string|max:16|unique:condomini,codice_fiscale,' . $condominio->id_condominio . ',id_condominio',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$condominio->update($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('condomini.index')->with('success', 'Condominio aggiornato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Condominio $condominio)
|
||||||
|
{
|
||||||
|
$condominio->delete();
|
||||||
|
return redirect()->route('condomini.index')->with('success', 'Condominio eliminato con successo.');
|
||||||
|
}
|
||||||
|
}
|
||||||
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
60
app/Http/Controllers/ProfileController.php
Normal file
60
app/Http/Controllers/ProfileController.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Requests\ProfileUpdateRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the user's profile form.
|
||||||
|
*/
|
||||||
|
public function edit(Request $request): View
|
||||||
|
{
|
||||||
|
return view('profile.edit', [
|
||||||
|
'user' => $request->user(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's profile information.
|
||||||
|
*/
|
||||||
|
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->user()->fill($request->validated());
|
||||||
|
|
||||||
|
if ($request->user()->isDirty('email')) {
|
||||||
|
$request->user()->email_verified_at = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->save();
|
||||||
|
|
||||||
|
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the user's account.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validateWithBag('userDeletion', [
|
||||||
|
'password' => ['required', 'current_password'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return Redirect::to('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
177
app/Http/Controllers/SuperAdmin/AmministratoreController.php
Normal file
177
app/Http/Controllers/SuperAdmin/AmministratoreController.php
Normal file
|
|
@ -0,0 +1,177 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\SuperAdmin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Amministratore;
|
||||||
|
use App\Models\User;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class AmministratoreController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Proteggi le rotte con i permessi di Spatie
|
||||||
|
$this->middleware('permission:view-amministratori', ['only' => ['index']]); // Permesso per visualizzare la lista
|
||||||
|
$this->middleware('permission:manage-amministratori', ['except' => ['index']]); // Permesso per tutte le altre azioni CRUD
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Gate::authorize('view-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
$amministratori = Amministratore::with('user')->paginate(10);
|
||||||
|
return view('superadmin.amministratori.index', compact('amministratori'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Gate::authorize('manage-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
$usersForSelect = User::doesntHave('amministratore')->get();
|
||||||
|
// In questo metodo, non c'è un $amministratore esistente, quindi non c'è un utente associato da includere.
|
||||||
|
return view('superadmin.amministratori.create', compact('usersForSelect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Gate::authorize('manage-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|string|email|max:255|unique:users,email',
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
'nome' => 'required|string|max:255',
|
||||||
|
'cognome' => 'required|string|max:255',
|
||||||
|
'denominazione_studio' => 'nullable|string|max:255',
|
||||||
|
'partita_iva' => 'nullable|string|max:20|unique:amministratori,partita_iva',
|
||||||
|
'codice_fiscale_studio' => 'nullable|string|max:20',
|
||||||
|
'indirizzo_studio' => 'nullable|string|max:255',
|
||||||
|
'cap_studio' => 'nullable|string|max:10',
|
||||||
|
'citta_studio' => 'nullable|string|max:60',
|
||||||
|
'provincia_studio' => 'nullable|string|max:2',
|
||||||
|
'telefono_studio' => 'nullable|string|max:20',
|
||||||
|
'email_studio' => 'nullable|string|email|max:255',
|
||||||
|
'pec_studio' => 'nullable|string|email|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
]);
|
||||||
|
$user->assignRole('admin'); // Assegna il ruolo 'admin' al nuovo utente per coerenza con le rotte
|
||||||
|
|
||||||
|
Amministratore::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'nome' => $request->nome,
|
||||||
|
'cognome' => $request->cognome,
|
||||||
|
'denominazione_studio' => $request->denominazione_studio,
|
||||||
|
'partita_iva' => $request->partita_iva,
|
||||||
|
'codice_fiscale_studio' => $request->codice_fiscale_studio,
|
||||||
|
'indirizzo_studio' => $request->indirizzo_studio,
|
||||||
|
'cap_studio' => $request->cap_studio,
|
||||||
|
'citta_studio' => $request->citta_studio,
|
||||||
|
'provincia_studio' => $request->provincia_studio,
|
||||||
|
'telefono_studio' => $request->telefono_studio,
|
||||||
|
'email_studio' => $request->email_studio,
|
||||||
|
'pec_studio' => $request->pec_studio,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.amministratori.index')->with('success', 'Amministratore creato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Amministratore $amministratore) // Aggiunto metodo edit
|
||||||
|
{
|
||||||
|
// Gate::authorize('manage-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
$usersForSelect = User::doesntHave('amministratore')->get();
|
||||||
|
|
||||||
|
// Includi l'utente attualmente collegato a questo amministratore nella lista, solo se esiste
|
||||||
|
if ($amministratore->user) {
|
||||||
|
$usersForSelect->push($amministratore->user);
|
||||||
|
}
|
||||||
|
return view('superadmin.amministratori.edit', compact('amministratore', 'usersForSelect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Amministratore $amministratore)
|
||||||
|
{
|
||||||
|
// Gate::authorize('manage-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
// L'utente associato all'amministratore.
|
||||||
|
$user = $amministratore->user;
|
||||||
|
|
||||||
|
// Se per qualche motivo l'utente non esiste, non possiamo procedere.
|
||||||
|
if (!$user) {
|
||||||
|
return redirect()->route('superadmin.amministratori.index')->with('error', 'Errore: Impossibile modificare. Utente associato non trovato.');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
// Dati dell'utente associato
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
|
||||||
|
|
||||||
|
// Dati del profilo amministratore
|
||||||
|
'user_id' => ['required', 'exists:users,id', Rule::unique('amministratori')->ignore($amministratore->id_amministratore, 'id_amministratore')],
|
||||||
|
'nome' => 'required|string|max:255',
|
||||||
|
'cognome' => 'required|string|max:255',
|
||||||
|
'denominazione_studio' => 'nullable|string|max:255',
|
||||||
|
'partita_iva' => ['nullable', 'string', 'max:20', Rule::unique('amministratori')->ignore($amministratore->id_amministratore, 'id_amministratore')],
|
||||||
|
'codice_fiscale_studio' => 'nullable|string|max:20',
|
||||||
|
'indirizzo_studio' => 'nullable|string|max:255',
|
||||||
|
'cap_studio' => 'nullable|string|max:10',
|
||||||
|
'citta_studio' => 'nullable|string|max:255',
|
||||||
|
'provincia_studio' => 'nullable|string|max:2',
|
||||||
|
'telefono_studio' => 'nullable|string|max:20',
|
||||||
|
'email_studio' => 'nullable|email|max:255',
|
||||||
|
'pec_studio' => 'nullable|email|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Aggiorna i dati dell'utente associato
|
||||||
|
$user->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Aggiorna i dati dell'amministratore, escludendo i campi dell'utente
|
||||||
|
$amministratore->update($request->except(['name', 'email', 'password']));
|
||||||
|
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.amministratori.index')->with('success', 'Amministratore aggiornato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Amministratore $amministratore)
|
||||||
|
{
|
||||||
|
// Gate::authorize('manage-amministratori'); // Il middleware nel costruttore è sufficiente
|
||||||
|
// Elimina l'utente associato, solo se esiste
|
||||||
|
if ($amministratore->user) {
|
||||||
|
$amministratore->user->delete();
|
||||||
|
}
|
||||||
|
$amministratore->delete();
|
||||||
|
return redirect()->route('superadmin.amministratori.index')->with('success', 'Amministratore eliminato con successo.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\SuperAdmin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\CategoriaTicket;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate; // Aggiunto per Gate
|
||||||
|
|
||||||
|
class CategoriaTicketController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// Proteggi le rotte con permessi specifici per il Super Admin
|
||||||
|
$this->middleware('permission:view-categorie-ticket', ['only' => ['index', 'show']]);
|
||||||
|
$this->middleware('permission:manage-categorie-ticket', ['only' => ['create', 'store', 'edit', 'update', 'destroy']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$categorieTicket = CategoriaTicket::paginate(10); // Variabile correttamente definita
|
||||||
|
return view('superadmin.categorie_ticket.index', compact('categorieTicket')); // Passa la variabile con il nome corretto
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('superadmin.categorie_ticket.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nome' => 'required|string|max:255|unique:categorie_ticket,nome',
|
||||||
|
'descrizione' => 'nullable|string|max:500',
|
||||||
|
]);
|
||||||
|
|
||||||
|
CategoriaTicket::create($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.categorie-ticket.index')->with('success', 'Categoria Ticket creata con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(CategoriaTicket $categoriaTicket)
|
||||||
|
{
|
||||||
|
// Non useremo una vista show separata per le categorie ticket,
|
||||||
|
// ma il metodo è richiesto dalle rotte resource.
|
||||||
|
// Potresti reindirizzare o mostrare un messaggio di errore.
|
||||||
|
return redirect()->route('superadmin.categorie-ticket.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(CategoriaTicket $categoriaTicket)
|
||||||
|
{
|
||||||
|
return view('superadmin.categorie_ticket.edit', compact('categoriaTicket'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, CategoriaTicket $categoriaTicket)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nome' => 'required|string|max:255|unique:categorie_ticket,nome,' . $categoriaTicket->id,
|
||||||
|
'descrizione' => 'nullable|string|max:500',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$categoriaTicket->update($request->all());
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.categorie-ticket.index')->with('success', 'Categoria Ticket aggiornata con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(CategoriaTicket $categoriaTicket)
|
||||||
|
{
|
||||||
|
// Prima di eliminare, considera se ci sono ticket associati a questa categoria.
|
||||||
|
// Se sì, potresti voler impedire l'eliminazione o riassegnare i ticket.
|
||||||
|
// Per ora, l'eliminazione è diretta.
|
||||||
|
$categoriaTicket->delete();
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.categorie-ticket.index')->with('success', 'Categoria Ticket eliminata con successo.');
|
||||||
|
}
|
||||||
|
}
|
||||||
129
app/Http/Controllers/SuperAdmin/UserController.php
Normal file
129
app/Http/Controllers/SuperAdmin/UserController.php
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Http\Controllers\SuperAdmin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{ // Proteggi le rotte con permessi specifici per il Super Admin
|
||||||
|
$this->middleware('permission:view-users', ['only' => ['index']]);
|
||||||
|
$this->middleware('permission:create-users', ['only' => ['create', 'store']]);
|
||||||
|
$this->middleware('permission:manage-users', ['only' => ['create', 'store', 'edit', 'update', 'destroy', 'updateRole']]);
|
||||||
|
$this->middleware('permission:impersonate-users', ['only' => ['impersonate']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
$users = User::with('roles')->paginate(10);
|
||||||
|
$roles = Role::all(); // Per la selezione dei ruoli nella vista
|
||||||
|
return view('superadmin.users.index', compact('users', 'roles'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{ // <-- QUESTA PARENTESI MANCAVA!
|
||||||
|
$roles = Role::all(); // Definisci $roles qui
|
||||||
|
return view('superadmin.users.create', compact('roles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255', // Aggiunto 'name' alla validazione
|
||||||
|
'email' => 'required|string|email|max:255|unique:users',
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
'role' => 'required|exists:roles,name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->assignRole($request->role);
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.users.index')->with('success', 'Utente creato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(User $user)
|
||||||
|
{
|
||||||
|
$roles = Role::all();
|
||||||
|
// Verifica che l'utente corrente abbia i permessi per modificare gli utenti
|
||||||
|
return view('superadmin.users.edit', compact('user', 'roles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, User $user)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')->ignore($user)],
|
||||||
|
'role' => 'required|exists:roles,name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->syncRoles([$request->role]); // Assegna il nuovo ruolo all'utente
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.users.index')->with('success', 'Utente aggiornato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateRole(Request $request, User $user)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'role' => 'required|exists:roles,name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($user->id === auth()->id()) {
|
||||||
|
return redirect()->route('superadmin.users.index')->with('error', 'Non puoi modificare il tuo stesso ruolo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->syncRoles([$request->role]); // Assegna il nuovo ruolo all'utente
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.users.index')->with('status', 'Ruolo utente aggiornato!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(User $user)
|
||||||
|
{
|
||||||
|
// Impedisci al Super Admin di eliminare il proprio account
|
||||||
|
if ($user->id === Auth::id()) {
|
||||||
|
return redirect()->route('superadmin.users.index')->with('error', 'Non puoi eliminare il tuo stesso account.');
|
||||||
|
}
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
return redirect()->route('superadmin.users.index')->with('success', 'Utente eliminato con successo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function impersonate(User $user)
|
||||||
|
{
|
||||||
|
$impersonator = Auth::user();
|
||||||
|
|
||||||
|
// Verifica che l'utente corrente possa impersonare e che l'utente target possa essere impersonato
|
||||||
|
if (!Gate::allows('impersonate', $impersonator)) {
|
||||||
|
return back()->with('error', 'Non hai i permessi per impersonare utenti.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica se l'utente target può essere impersonato
|
||||||
|
if (!Gate::allows('canBeImpersonated', $user)) {
|
||||||
|
return back()->with('error', 'Questo utente non può essere impersonato.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$impersonator->impersonate($user);
|
||||||
|
return redirect('/dashboard')->with('status', 'Ora stai impersonando ' . $user->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/Http/Controllers/SuperAdmin/test-auth.php
Normal file
5
app/Http/Controllers/SuperAdmin/test-auth.php
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
@php
|
||||||
|
$roles = is_array(Auth::user()->roles ?? null)
|
||||||
|
? Auth::user()->roles
|
||||||
|
: explode(',', Auth::user()->role ?? '');
|
||||||
|
@endphp
|
||||||
2
app/Http/Controllers/SuperAdmin/test.php
Normal file
2
app/Http/Controllers/SuperAdmin/test.php
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?php
|
||||||
|
Route::get('/test', fn () => 'ok superadmin');
|
||||||
71
app/Http/Kernel.php
Normal file
71
app/Http/Kernel.php
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
// \App\Http\Middleware\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Illuminate\Http\Middleware\HandleCors::class,
|
||||||
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, class-string|string>>
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
|
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, // Ripristina il middleware guest predefinito di Laravel
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||||
|
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||||
|
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
41
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
41
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||||
|
{
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (Auth::guard($guard)->check()) { // Se l'utente è autenticato...
|
||||||
|
$user = Auth::user(); // ...recupera l'utente
|
||||||
|
|
||||||
|
// Reindirizza l'utente alla dashboard specifica del suo ruolo
|
||||||
|
if ($user->hasRole('super-admin')) { return redirect()->route('superadmin.dashboard'); }
|
||||||
|
if ($user->hasRole(['admin', 'amministratore'])) { return redirect()->route('admin.dashboard'); }
|
||||||
|
if ($user->hasRole('condomino')) { return redirect()->route('condomino.dashboard'); }
|
||||||
|
|
||||||
|
// Fallback per utenti autenticati senza un ruolo specifico o con un ruolo non gestito
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Se l'utente non è autenticato, continua con la richiesta
|
||||||
|
// Questo permette di accedere alle rotte pubbliche come login, registrazione, ecc
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Lockout;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class LoginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => ['required', 'string', 'email'],
|
||||||
|
'password' => ['required', 'string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to authenticate the request's credentials.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function authenticate(): void
|
||||||
|
{
|
||||||
|
$this->ensureIsNotRateLimited();
|
||||||
|
|
||||||
|
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||||
|
RateLimiter::hit($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.failed'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::clear($this->throttleKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the login request is not rate limited.
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function ensureIsNotRateLimited(): void
|
||||||
|
{
|
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event(new Lockout($this));
|
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.throttle', [
|
||||||
|
'seconds' => $seconds,
|
||||||
|
'minutes' => ceil($seconds / 60),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rate limiting throttle key for the request.
|
||||||
|
*/
|
||||||
|
public function throttleKey(): string
|
||||||
|
{
|
||||||
|
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
30
app/Http/Requests/ProfileUpdateRequest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ProfileUpdateRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'lowercase',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique(User::class)->ignore($this->user()->id),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
94
app/Livewire/Contabilita/RegistrazioneTest.php
Normal file
94
app/Livewire/Contabilita/RegistrazioneTest.php
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Contabilita;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class RegistrazioneTest extends Component
|
||||||
|
{
|
||||||
|
public $fornitore_id;
|
||||||
|
public $data_documento;
|
||||||
|
public $descrizione;
|
||||||
|
public $importo_totale;
|
||||||
|
public $percentuale_ra = 0;
|
||||||
|
public $voci = [];
|
||||||
|
public $allegati = [];
|
||||||
|
public $conti = [];
|
||||||
|
public $tabelle = [];
|
||||||
|
public $fornitori = [];
|
||||||
|
public $totale_spese = 0;
|
||||||
|
public $totale_ra = 0;
|
||||||
|
public $totale_da_pagare = 0;
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->conti = [
|
||||||
|
['id' => 1, 'descrizione' => 'Manutenzione'],
|
||||||
|
['id' => 2, 'descrizione' => 'Pulizie'],
|
||||||
|
];
|
||||||
|
$this->tabelle = [
|
||||||
|
['id' => 1, 'nome_tabella' => 'Tabella A'],
|
||||||
|
['id' => 2, 'nome_tabella' => 'Tabella B'],
|
||||||
|
];
|
||||||
|
$this->fornitori = [
|
||||||
|
['id' => 1, 'nome' => 'Mario Rossi'],
|
||||||
|
['id' => 2, 'nome' => 'Studio Bianchi'],
|
||||||
|
];
|
||||||
|
$this->aggiungiVoce();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updated($property)
|
||||||
|
{
|
||||||
|
$this->ricalcolaTotali();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function aggiungiVoce()
|
||||||
|
{
|
||||||
|
$this->voci[] = [
|
||||||
|
'conto_id' => '',
|
||||||
|
'tabella_id' => '',
|
||||||
|
'descrizione' => '',
|
||||||
|
'importo' => 0,
|
||||||
|
'ra_imputata' => 0,
|
||||||
|
];
|
||||||
|
$this->ricalcolaTotali();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rimuoviVoce($index)
|
||||||
|
{
|
||||||
|
unset($this->voci[$index]);
|
||||||
|
$this->voci = array_values($this->voci);
|
||||||
|
$this->ricalcolaTotali();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ricalcolaTotali()
|
||||||
|
{
|
||||||
|
$this->totale_spese = collect($this->voci)->sum('importo');
|
||||||
|
$this->totale_ra = $this->percentuale_ra > 0
|
||||||
|
? round($this->totale_spese * $this->percentuale_ra / 100, 2)
|
||||||
|
: 0;
|
||||||
|
foreach ($this->voci as $i => $voce) {
|
||||||
|
$importo = $voce['importo'] ?? 0;
|
||||||
|
$this->voci[$i]['ra_imputata'] = $this->totale_spese > 0
|
||||||
|
? round($importo * $this->totale_ra / $this->totale_spese, 2)
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
$this->totale_da_pagare = $this->totale_spese - $this->totale_ra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function salvaRegistrazione()
|
||||||
|
{
|
||||||
|
session()->flash('success', 'Registrazione di prova salvata!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.contabilita.registrazione-test');
|
||||||
|
}
|
||||||
|
public static function layout()
|
||||||
|
{
|
||||||
|
return 'layouts.app';
|
||||||
|
}
|
||||||
|
}
|
||||||
66
app/Models/Amministratore.php
Normal file
66
app/Models/Amministratore.php
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany; // Aggiunto per condomini()
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes; // Aggiunto per soft deletes
|
||||||
|
|
||||||
|
class Amministratore extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'amministratori'; // Specifica il nome corretto della tabella
|
||||||
|
protected $primaryKey = 'id_amministratore';
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'nome',
|
||||||
|
'cognome',
|
||||||
|
'denominazione_studio',
|
||||||
|
'partita_iva',
|
||||||
|
'codice_fiscale_studio',
|
||||||
|
'indirizzo_studio',
|
||||||
|
'cap_studio',
|
||||||
|
'citta_studio',
|
||||||
|
'provincia_studio',
|
||||||
|
'telefono_studio',
|
||||||
|
'email_studio',
|
||||||
|
'pec_studio',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user associated with the Amministratore.
|
||||||
|
*/
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the condomini for the Amministratore.
|
||||||
|
*/
|
||||||
|
public function stabili(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Stabile::class, 'amministratore_id', 'id_amministratore');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the fornitori for the Amministratore.
|
||||||
|
*/
|
||||||
|
public function fornitori(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Fornitore::class, 'amministratore_id', 'id_amministratore');
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Models/CategoriaTicket.php
Normal file
21
app/Models/CategoriaTicket.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
|
||||||
|
class CategoriaTicket extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'categorie_ticket';
|
||||||
|
protected $fillable = ['nome', 'descrizione'];
|
||||||
|
|
||||||
|
public function tickets(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Ticket::class, 'categoria_ticket_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Models/ContoCorrente.php
Normal file
35
app/Models/ContoCorrente.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class ContoCorrente extends Model
|
||||||
|
{
|
||||||
|
use HasFactory; // Corretto il nome della tabella e la chiave primaria
|
||||||
|
protected $table = 'conti_condominio'; // Corretto il nome della tabella
|
||||||
|
protected $primaryKey = 'id_conto_condominio'; // Chiave primaria corretta
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'id_condominio', // Corretto il nome della colonna
|
||||||
|
'codice_conto',
|
||||||
|
'nome_conto',
|
||||||
|
'iban',
|
||||||
|
'bic_swift',
|
||||||
|
'nome_banca',
|
||||||
|
'filiale_banca',
|
||||||
|
'tipo_conto',
|
||||||
|
'saldo_iniziale',
|
||||||
|
'data_saldo_iniziale',
|
||||||
|
'valuta',
|
||||||
|
'attivo',
|
||||||
|
'note',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function condominio(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Condominio::class, 'id_condominio', 'id_condominio');
|
||||||
|
}
|
||||||
|
}
|
||||||
12
app/Models/Gruppo.php
Normal file
12
app/Models/Gruppo.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
class Gruppo extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'gruppi';
|
||||||
|
protected $fillable = ['nome_gruppo', 'manager_id'];
|
||||||
|
public function manager() { return $this->belongsTo(User::class, 'manager_id'); }
|
||||||
|
public function amministratori() { return $this->hasMany(Amministratore::class); }
|
||||||
|
}
|
||||||
38
app/Models/PianoContiCondominio.php
Normal file
38
app/Models/PianoContiCondominio.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
|
||||||
|
class PianoContiCondominio extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'piano_conti_condominio';
|
||||||
|
protected $primaryKey = 'id_conto_condominio_pc';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'id_stabile',
|
||||||
|
'id_conto_modello_riferimento',
|
||||||
|
'codice',
|
||||||
|
'descrizione',
|
||||||
|
'tipo_conto',
|
||||||
|
'is_conto_finanziario',
|
||||||
|
'attivo',
|
||||||
|
'note',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function stabile(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Stabile::class, 'id_stabile', 'id_stabile');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function vociPreventivo(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(VocePreventivo::class, 'id_piano_conto_condominio_pc', 'id_conto_condominio_pc');
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Models/PianoContoModello.php
Normal file
31
app/Models/PianoContoModello.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
|
||||||
|
class PianoContoModello extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'piani_conti_modello';
|
||||||
|
protected $primaryKey = 'id_conto_modello';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'codice',
|
||||||
|
'descrizione',
|
||||||
|
'tipo_conto',
|
||||||
|
'natura_saldo_tipico',
|
||||||
|
'is_conto_finanziario',
|
||||||
|
'note',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function pianoContiCondominio(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(PianoContoCondominio::class, 'id_conto_modello_riferimento', 'id_conto_modello');
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Models/Proprieta.php
Normal file
23
app/Models/Proprieta.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Proprieta extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'proprieta';
|
||||||
|
protected $fillable = [
|
||||||
|
'unita_immobiliare_id', 'soggetto_id', 'tipo_diritto',
|
||||||
|
'percentuale_possesso', 'data_inizio', 'data_fine', 'note'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function unitaImmobiliare() {
|
||||||
|
return $this->belongsTo(UnitaImmobiliare::class, 'unita_immobiliare_id', 'id_unita');
|
||||||
|
}
|
||||||
|
public function soggetto() {
|
||||||
|
return $this->belongsTo(Soggetto::class, 'soggetto_id', 'id_soggetto');
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/Models/RigaMovimentoContabile.php
Normal file
52
app/Models/RigaMovimentoContabile.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RigaMovimentoContabile extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'righe_movimenti_contabili';
|
||||||
|
protected $primaryKey = 'id_riga_movimento';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'id_transazione',
|
||||||
|
'id_piano_conto_condominio_pc',
|
||||||
|
'id_gestione_imputazione',
|
||||||
|
'descrizione_riga',
|
||||||
|
'importo_dare',
|
||||||
|
'importo_avere',
|
||||||
|
'id_unita_immobiliare',
|
||||||
|
'id_soggetto',
|
||||||
|
'id_fornitore',
|
||||||
|
'id_voce_spesa_originale',
|
||||||
|
'note_riga',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function transazione(): BelongsTo { return $this->belongsTo(TransazioneContabile::class, 'id_transazione', 'id_transazione'); }
|
||||||
|
public function pianoContoCondominio(): BelongsTo { return $this->belongsTo(PianoContoCondominio::class, 'id_piano_conto_condominio_pc', 'id_conto_condominio_pc'); }
|
||||||
|
public function gestioneImputazione(): BelongsTo { return $this->belongsTo(Gestione::class, 'id_gestione_imputazione', 'id_gestione'); }
|
||||||
|
public function unitaImmobiliare(): BelongsTo { return $this->belongsTo(UnitaImmobiliare::class, 'id_unita_immobiliare', 'id_unita'); }
|
||||||
|
public function soggetto(): BelongsTo { return $this->belongsTo(Soggetto::class, 'id_soggetto', 'id_soggetto'); }
|
||||||
|
public function fornitore(): BelongsTo { return $this->belongsTo(Fornitore::class, 'id_fornitore', 'id_fornitore'); }
|
||||||
|
public function voceSpesaOriginale(): BelongsTo { return $this->belongsTo(VoceSpesa::class, 'id_voce_spesa_originale', 'id_voce'); }
|
||||||
|
}
|
||||||
|
// Compare this snippet from netgescon-laravel/app/Models/TransazioneContabile.php:
|
||||||
|
// <?php
|
||||||
|
//
|
||||||
|
// namespace App\Models;
|
||||||
|
//
|
||||||
|
// use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
// use Illuminate\Database\Eloquent\Model;
|
||||||
|
// use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
// use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
// use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
//
|
||||||
56
app/Models/Soggetto.php
Normal file
56
app/Models/Soggetto.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Soggetto extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'soggetti';
|
||||||
|
protected $primaryKey = 'id_soggetto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'old_id',
|
||||||
|
'nome',
|
||||||
|
'cognome',
|
||||||
|
'ragione_sociale',
|
||||||
|
'codice_fiscale',
|
||||||
|
'partita_iva',
|
||||||
|
'email',
|
||||||
|
'telefono',
|
||||||
|
'indirizzo',
|
||||||
|
'cap',
|
||||||
|
'citta',
|
||||||
|
'provincia',
|
||||||
|
'tipo',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The units that belong to the subject.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function ticketsRichiesti(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Ticket::class, 'soggetto_richiedente_id', 'id_soggetto');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rateEmessaResponsabile(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(RataEmessa::class, 'id_soggetto_responsabile', 'id_soggetto');
|
||||||
|
}
|
||||||
|
// In Soggetto.php
|
||||||
|
public function proprieta() {
|
||||||
|
return $this->hasMany(Proprieta::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
app/Models/TicketAttachment.php
Normal file
32
app/Models/TicketAttachment.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class TicketAttachment extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'ticket_attachments';
|
||||||
|
protected $fillable = ['ticket_id', 'ticket_update_id', 'user_id', 'file_path', 'original_file_name', 'mime_type', 'size', 'description'];
|
||||||
|
|
||||||
|
public function ticket(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Ticket::class, 'ticket_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ticketUpdate(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(TicketUpdate::class, 'ticket_update_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Models/TicketMessage.php
Normal file
19
app/Models/TicketMessage.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class TicketMessage extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = ['ticket_id', 'user_id', 'messaggio'];
|
||||||
|
|
||||||
|
public function ticket(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Ticket::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo { return $this->belongsTo(User::class); }
|
||||||
|
}
|
||||||
27
app/Models/TicketUpdate.php
Normal file
27
app/Models/TicketUpdate.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class TicketUpdate extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'ticket_updates';
|
||||||
|
protected $fillable = ['ticket_id', 'user_id', 'update_text'];
|
||||||
|
|
||||||
|
public function ticket(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Ticket::class, 'ticket_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||||
|
}
|
||||||
|
}
|
||||||
74
app/Models/TransazioneContabile.php
Normal file
74
app/Models/TransazioneContabile.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class TransazioneContabile extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
protected $table = 'transazioni_contabili';
|
||||||
|
protected $primaryKey = 'id_transazione';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'id_condominio',
|
||||||
|
'id_gestione',
|
||||||
|
'data_registrazione',
|
||||||
|
'data_documento',
|
||||||
|
'data_competenza',
|
||||||
|
'numero_protocollo_interno',
|
||||||
|
'protocollo_gestione_tipo',
|
||||||
|
'anno_protocollo_documento',
|
||||||
|
'data_protocollo',
|
||||||
|
'tipo_documento_origine',
|
||||||
|
'riferimento_documento_esterno',
|
||||||
|
'descrizione_generale',
|
||||||
|
'importo_totale_transazione',
|
||||||
|
'stato_transazione',
|
||||||
|
'id_utente_registrazione',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'data_registrazione' => 'date',
|
||||||
|
'data_documento' => 'date',
|
||||||
|
'data_competenza' => 'date',
|
||||||
|
'data_protocollo' => 'date',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function condominio(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Condominio::class, 'id_condominio', 'id_condominio');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gestione(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Gestione::class, 'id_gestione', 'id_gestione');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function righeMovimenti(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(RigaMovimentoContabile::class, 'id_transazione', 'id_transazione');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se hai una tabella 'users' per gli utenti che registrano i movimenti
|
||||||
|
public function utenteRegistrazione(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'id_utente_registrazione');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -50,18 +50,24 @@ class UnitaImmobiliare extends Model
|
||||||
return $this->hasMany(Ticket::class, 'unita_immobiliare_id', 'id_unita');
|
return $this->hasMany(Ticket::class, 'unita_immobiliare_id', 'id_unita');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relazione con Proprietà
|
||||||
|
*/
|
||||||
|
public function proprieta()
|
||||||
|
{
|
||||||
|
return $this->hasMany(\App\Models\Proprieta::class, 'unita_immobiliare_id', 'id_unita');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessor per identificazione completa dell'unità
|
* Accessor per identificazione completa dell'unità
|
||||||
*/
|
*/
|
||||||
public function getIdentificazioneCompiletaAttribute()
|
public function getIdentificazioneCompiletaAttribute()
|
||||||
{
|
{
|
||||||
$parts = [];
|
$parts = [];
|
||||||
|
|
||||||
if ($this->fabbricato) $parts[] = 'Fabb. ' . $this->fabbricato;
|
if ($this->fabbricato) $parts[] = 'Fabb. ' . $this->fabbricato;
|
||||||
if ($this->scala) $parts[] = 'Scala ' . $this->scala;
|
if ($this->scala) $parts[] = 'Scala ' . $this->scala;
|
||||||
if ($this->piano) $parts[] = 'Piano ' . $this->piano;
|
if ($this->piano) $parts[] = 'Piano ' . $this->piano;
|
||||||
if ($this->interno) $parts[] = 'Int. ' . $this->interno;
|
if ($this->interno) $parts[] = 'Int. ' . $this->interno;
|
||||||
|
|
||||||
return implode(', ', $parts) ?: 'N/A';
|
return implode(', ', $parts) ?: 'N/A';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
59
app/Models/User.php
Normal file
59
app/Models/User.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
// Import necessari
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Lab404\Impersonate\Models\Impersonate; // Per la funzionalità di impersonificazione
|
||||||
|
use Spatie\Permission\Traits\HasRoles; // Per la gestione dei ruoli e permessi
|
||||||
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
// Aggiungi il trait Impersonate
|
||||||
|
use HasApiTokens, HasFactory, Notifiable, Impersonate, HasRoles; // Aggiungi HasRoles qui
|
||||||
|
|
||||||
|
|
||||||
|
protected $fillable = ['name', 'email', 'password', 'email_verified_at']; // Aggiunto email_verified_at
|
||||||
|
protected $hidden = ['password', 'remember_token'];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return ['email_verified_at' => 'datetime', 'password' => 'hashed'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amministratore record associated with the user.
|
||||||
|
*/
|
||||||
|
public function amministratore(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Amministratore::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tickets(): HasMany { return $this->hasMany(Ticket::class, 'aperto_da_user_id'); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regola per il pacchetto: definisce se l'utente ATTUALE
|
||||||
|
* ha il permesso di impersonare altri.
|
||||||
|
*/
|
||||||
|
public function canImpersonate(): bool
|
||||||
|
|
||||||
|
{
|
||||||
|
// Solo il Super-Admin può farlo.
|
||||||
|
return $this->hasRole('super-admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regola per il pacchetto: definisce se questo specifico
|
||||||
|
* utente PUÒ ESSERE impersonato.
|
||||||
|
*/
|
||||||
|
public function canBeImpersonated(): bool
|
||||||
|
{
|
||||||
|
// Solo gli utenti con ruolo 'admin' possono essere impersonati.
|
||||||
|
return $this->hasRole('admin');
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Policies/StabilePolicy.php
Normal file
49
app/Policies/StabilePolicy.php
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\Stabile;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
|
|
||||||
|
class StabilePolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, Stabile $stabile): bool
|
||||||
|
{
|
||||||
|
// L'utente può vedere lo stabile solo se è l'amministratore associato a quello stabile.
|
||||||
|
// L'operatore '?->' (nullsafe) previene errori se l'utente non ha un profilo amministratore.
|
||||||
|
return $user->amministratore?->id_amministratore === $stabile->amministratore_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
// Qualsiasi utente con il permesso 'manage-stabili' può creare uno stabile.
|
||||||
|
return $user->can('manage-stabili');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, Stabile $stabile): bool
|
||||||
|
{
|
||||||
|
// L'utente può modificare lo stabile solo se ne è l'amministratore associato e ha il permesso.
|
||||||
|
return $user->amministratore?->id_amministratore === $stabile->amministratore_id
|
||||||
|
&& $user->can('manage-stabili');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, Stabile $stabile): bool
|
||||||
|
{
|
||||||
|
// L'utente può eliminare lo stabile solo se ne è l'amministratore associato e ha il permesso.
|
||||||
|
return $user->amministratore?->id_amministratore === $stabile->amministratore_id
|
||||||
|
&& $user->can('manage-stabili');
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Providers/AppServiceProvider.php
Normal file
25
app/Providers/AppServiceProvider.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
// Al momento non usiamo più la logica di Fortify qui,
|
||||||
|
// ma lasciamo il file pulito per future necessità.
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Providers/AuthServiceProvider.php
Normal file
56
app/Providers/AuthServiceProvider.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Stabile;
|
||||||
|
use App\Policies\StabilePolicy;
|
||||||
|
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model to policy mappings for the application.
|
||||||
|
* @var array<class-string, class-string>
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
//
|
||||||
|
Stabile::class => StabilePolicy::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any authentication / authorization services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
// Gate per accesso pannello super-admin
|
||||||
|
Gate::define('access-super-admin-panel', function (User $user) {
|
||||||
|
return $user->hasRole('super-admin');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gate per accesso pannello admin (Amministratore di Condominio)
|
||||||
|
Gate::define('access-admin-panel', function (User $user) {
|
||||||
|
// L'utente deve avere il ruolo 'amministratore' ED essere collegato a un record 'amministratori'
|
||||||
|
return $user->hasRole('amministratore') && $user->amministratore()->exists();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gate per accesso pannello condomino
|
||||||
|
Gate::define('access-condomino-panel', function (User $user) {
|
||||||
|
return $user->hasRole('condomino');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gate per l'impersonificazione
|
||||||
|
Gate::define('impersonate', function (User $user) {
|
||||||
|
// Solo i super-admin possono impersonare
|
||||||
|
return $user->hasRole('super-admin');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gate per verificare se un utente può essere impersonato
|
||||||
|
Gate::define('canBeImpersonated', function (User $user, User $targetUser) {
|
||||||
|
// Un super-admin non può essere impersonato da nessuno
|
||||||
|
return !$targetUser->hasRole('super-admin');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
37
app/Providers/EventServiceProvider.php
Normal file
37
app/Providers/EventServiceProvider.php
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The event to listener mappings for the application.
|
||||||
|
* @var array<class-string, array<int, class-string>>
|
||||||
|
*/
|
||||||
|
protected $listen = [
|
||||||
|
Registered::class => [
|
||||||
|
SendEmailVerificationNotification::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any events for your application.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if events and listeners should be automatically discovered.
|
||||||
|
*/
|
||||||
|
public function shouldDiscoverEvents(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Providers/RouteServiceProvider.php
Normal file
40
app/Providers/RouteServiceProvider.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path to your application's "home" route.
|
||||||
|
*
|
||||||
|
* Typically, users are redirected here after authentication.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const HOME = '/dashboard'; // Reindirizza sempre a /dashboard dopo il login
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define your route model bindings, pattern filters, and other route configuration.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
RateLimiter::for('api', function (Request $request) {
|
||||||
|
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->routes(function () {
|
||||||
|
Route::middleware('api')
|
||||||
|
->prefix('api')
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
|
Route::middleware('web')
|
||||||
|
->group(base_path('routes/web.php'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/View/Components/AppLayout.php
Normal file
17
app/View/Components/AppLayout.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AppLayout extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represents the component.
|
||||||
|
*/
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/View/Components/GuestLayout.php
Normal file
17
app/View/Components/GuestLayout.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class GuestLayout extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represents the component.
|
||||||
|
*/
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('layouts.guest');
|
||||||
|
}
|
||||||
|
}
|
||||||
18
artisan
Executable file
18
artisan
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
// Register the Composer autoloader...
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
// Bootstrap Laravel and handle the command...
|
||||||
|
/** @var Application $app */
|
||||||
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
$status = $app->handleCommand(new ArgvInput);
|
||||||
|
|
||||||
|
exit($status);
|
||||||
23
bootstrap/app.php
Normal file
23
bootstrap/app.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
|
||||||
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
|
->withRouting(
|
||||||
|
web: __DIR__.'/../routes/web.php',
|
||||||
|
commands: __DIR__.'/../routes/console.php',
|
||||||
|
health: '/up',
|
||||||
|
)
|
||||||
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
|
// Registra gli alias dei middleware di Spatie Permission (NAMESPACE CORRETTO)
|
||||||
|
$middleware->alias([
|
||||||
|
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||||
|
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||||
|
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
->withExceptions(function (Exceptions $exceptions) {
|
||||||
|
//
|
||||||
|
})->create();
|
||||||
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
||||||
5
bootstrap/providers.php
Normal file
5
bootstrap/providers.php
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
];
|
||||||
85
composer.json
Normal file
85
composer.json
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://getcomposer.org/schema.json",
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The skeleton application for the Laravel framework.",
|
||||||
|
"keywords": [
|
||||||
|
"laravel",
|
||||||
|
"framework"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.2",
|
||||||
|
"lab404/laravel-impersonate": "^1.7",
|
||||||
|
"laravel/fortify": "^1.26",
|
||||||
|
"laravel/framework": "^12.0",
|
||||||
|
"laravel/sanctum": "^4.1",
|
||||||
|
"laravel/tinker": "^2.10.1",
|
||||||
|
"livewire/livewire": "^3.6",
|
||||||
|
"spatie/laravel-permission": "^6.20"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/breeze": "^2.3",
|
||||||
|
"laravel/pail": "^1.2.2",
|
||||||
|
"laravel/pint": "^1.13",
|
||||||
|
"laravel/sail": "^1.41",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"nunomaduro/collision": "^8.6",
|
||||||
|
"pestphp/pest": "^3.8",
|
||||||
|
"pestphp/pest-plugin-laravel": "^3.2"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"post-autoload-dump": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
|
"@php artisan package:discover --ansi"
|
||||||
|
],
|
||||||
|
"post-update-cmd": [
|
||||||
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||||
|
],
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
],
|
||||||
|
"post-create-project-cmd": [
|
||||||
|
"@php artisan key:generate --ansi",
|
||||||
|
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||||
|
"@php artisan migrate --graceful --ansi"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||||
|
],
|
||||||
|
"test": [
|
||||||
|
"@php artisan config:clear --ansi",
|
||||||
|
"@php artisan test"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true,
|
||||||
|
"php-http/discovery": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
||||||
9664
composer.lock
generated
Normal file
9664
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
112
config/app.php
Normal file
112
config/app.php
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
use Illuminate\Support\ServiceProvider; // <-- La riga che risolve l'errore
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Debug Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application URL
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
'asset_url' => env('ASSET_URL'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => 'en',
|
||||||
|
|
||||||
|
'fallback_locale' => 'en',
|
||||||
|
|
||||||
|
'faker_locale' => 'en_US',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maintenance Mode Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'maintenance' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
// 'store' => 'redis',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Autoloaded Service Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => ServiceProvider::defaultProviders()->merge([
|
||||||
|
/*
|
||||||
|
* Application Service Providers...
|
||||||
|
*/
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\AuthServiceProvider::class, // <-- La nostra riga fondamentale è qui
|
||||||
|
App\Providers\EventServiceProvider::class,
|
||||||
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
Spatie\Permission\PermissionServiceProvider::class,
|
||||||
|
|
||||||
|
])->toArray(),
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Class Aliases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'aliases' => Facade::defaultAliases()->merge([
|
||||||
|
// 'Example' => App\Facades\Example::class,
|
||||||
|
])->toArray(),
|
||||||
|
|
||||||
|
];
|
||||||
115
config/auth.php
Normal file
115
config/auth.php
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Defaults
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default authentication "guard" and password
|
||||||
|
| reset "broker" for your application. You may change these values
|
||||||
|
| as required, but they're a perfect start for most applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'defaults' => [
|
||||||
|
'guard' => env('AUTH_GUARD', 'web'),
|
||||||
|
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, you may define every authentication guard for your application.
|
||||||
|
| Of course, a great default configuration has been defined for you
|
||||||
|
| which utilizes session storage plus the Eloquent user provider.
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| Supported: "session"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guards' => [
|
||||||
|
'web' => [
|
||||||
|
'driver' => 'session',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| If you have multiple user tables or models you may configure multiple
|
||||||
|
| providers to represent the model / table. These providers may then
|
||||||
|
| be assigned to any extra authentication guards you have defined.
|
||||||
|
|
|
||||||
|
| Supported: "database", "eloquent"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
'users' => [
|
||||||
|
'driver' => 'eloquent',
|
||||||
|
'model' => env('AUTH_MODEL', App\Models\User::class),
|
||||||
|
],
|
||||||
|
|
||||||
|
// 'users' => [
|
||||||
|
// 'driver' => 'database',
|
||||||
|
// 'table' => 'users',
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Resetting Passwords
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options specify the behavior of Laravel's password
|
||||||
|
| reset functionality, including the table utilized for token storage
|
||||||
|
| and the user provider that is invoked to actually retrieve users.
|
||||||
|
|
|
||||||
|
| The expiry time is the number of minutes that each reset token will be
|
||||||
|
| considered valid. This security feature keeps tokens short-lived so
|
||||||
|
| they have less time to be guessed. You may change this as needed.
|
||||||
|
|
|
||||||
|
| The throttle setting is the number of seconds a user must wait before
|
||||||
|
| generating more password reset tokens. This prevents the user from
|
||||||
|
| quickly generating a very large amount of password reset tokens.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'passwords' => [
|
||||||
|
'users' => [
|
||||||
|
'provider' => 'users',
|
||||||
|
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||||
|
'expire' => 60,
|
||||||
|
'throttle' => 60,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Confirmation Timeout
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define the number of seconds before a password confirmation
|
||||||
|
| window expires and users are asked to re-enter their password via the
|
||||||
|
| confirmation screen. By default, the timeout lasts for three hours.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||||
|
|
||||||
|
];
|
||||||
108
config/cache.php
Normal file
108
config/cache.php
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default cache store that will be used by the
|
||||||
|
| framework. This connection is utilized if another isn't explicitly
|
||||||
|
| specified when running a cache operation inside the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('CACHE_STORE', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Stores
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define all of the cache "stores" for your application as
|
||||||
|
| well as their drivers. You may even define multiple stores for the
|
||||||
|
| same cache driver to group types of items stored in your caches.
|
||||||
|
|
|
||||||
|
| Supported drivers: "array", "database", "file", "memcached",
|
||||||
|
| "redis", "dynamodb", "octane", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stores' => [
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'driver' => 'array',
|
||||||
|
'serialize' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_CACHE_CONNECTION'),
|
||||||
|
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||||
|
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||||
|
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'file' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
'path' => storage_path('framework/cache/data'),
|
||||||
|
'lock_path' => storage_path('framework/cache/data'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'memcached' => [
|
||||||
|
'driver' => 'memcached',
|
||||||
|
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||||
|
'sasl' => [
|
||||||
|
env('MEMCACHED_USERNAME'),
|
||||||
|
env('MEMCACHED_PASSWORD'),
|
||||||
|
],
|
||||||
|
'options' => [
|
||||||
|
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||||
|
],
|
||||||
|
'servers' => [
|
||||||
|
[
|
||||||
|
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MEMCACHED_PORT', 11211),
|
||||||
|
'weight' => 100,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||||
|
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'dynamodb' => [
|
||||||
|
'driver' => 'dynamodb',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||||
|
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'octane' => [
|
||||||
|
'driver' => 'octane',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Key Prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||||
|
| stores, there might be other applications using the same cache. For
|
||||||
|
| that reason, you may prefix every cache key to avoid collisions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||||
|
|
||||||
|
];
|
||||||
174
config/database.php
Normal file
174
config/database.php
Normal file
|
|
@ -0,0 +1,174 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Database Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which of the database connections below you wish
|
||||||
|
| to use as your default connection for database operations. This is
|
||||||
|
| the connection which will be utilized unless another connection
|
||||||
|
| is explicitly specified when you execute a query / statement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Database Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below are all of the database connections defined for your application.
|
||||||
|
| An example configuration is provided for each database system which
|
||||||
|
| is supported by Laravel. You're free to add / remove connections.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sqlite' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||||
|
'prefix' => '',
|
||||||
|
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||||
|
'busy_timeout' => null,
|
||||||
|
'journal_mode' => null,
|
||||||
|
'synchronous' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'mysql' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'mariadb' => [
|
||||||
|
'driver' => 'mariadb',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'pgsql' => [
|
||||||
|
'driver' => 'pgsql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '5432'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'search_path' => 'public',
|
||||||
|
'sslmode' => 'prefer',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqlsrv' => [
|
||||||
|
'driver' => 'sqlsrv',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
|
'port' => env('DB_PORT', '1433'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||||
|
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migration Repository Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This table keeps track of all the migrations that have already run for
|
||||||
|
| your application. Using this information, we can determine which of
|
||||||
|
| the migrations on disk haven't actually been run on the database.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'migrations' => [
|
||||||
|
'table' => 'migrations',
|
||||||
|
'update_date_on_publish' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Redis Databases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Redis is an open source, fast, and advanced key-value store that also
|
||||||
|
| provides a richer body of commands than a typical key-value system
|
||||||
|
| such as Memcached. You may define your connection settings here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
|
||||||
|
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
|
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||||
|
'persistent' => env('REDIS_PERSISTENT', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
'default' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_DB', '0'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_CACHE_DB', '1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
80
config/filesystems.php
Normal file
80
config/filesystems.php
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Filesystem Disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default filesystem disk that should be used
|
||||||
|
| by the framework. The "local" disk, as well as a variety of cloud
|
||||||
|
| based disks are available to your application for file storage.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filesystem Disks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below you may configure as many filesystem disks as necessary, and you
|
||||||
|
| may even configure multiple disks for the same driver. Examples for
|
||||||
|
| most supported storage drivers are configured here for reference.
|
||||||
|
|
|
||||||
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disks' => [
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/private'),
|
||||||
|
'serve' => true,
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'public' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public'),
|
||||||
|
'url' => env('APP_URL').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
's3' => [
|
||||||
|
'driver' => 's3',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION'),
|
||||||
|
'bucket' => env('AWS_BUCKET'),
|
||||||
|
'url' => env('AWS_URL'),
|
||||||
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Symbolic Links
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the symbolic links that will be created when the
|
||||||
|
| `storage:link` Artisan command is executed. The array keys should be
|
||||||
|
| the locations of the links and the values should be their targets.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'links' => [
|
||||||
|
public_path('storage') => storage_path('app/public'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
132
config/logging.php
Normal file
132
config/logging.php
Normal file
|
|
@ -0,0 +1,132 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Monolog\Handler\NullHandler;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\SyslogUdpHandler;
|
||||||
|
use Monolog\Processor\PsrLogMessageProcessor;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default log channel that is utilized to write
|
||||||
|
| messages to your logs. The value provided here should match one of
|
||||||
|
| the channels present in the list of "channels" configured below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('LOG_CHANNEL', 'stack'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Deprecations Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the log channel that should be used to log warnings
|
||||||
|
| regarding deprecated PHP and library features. This allows you to get
|
||||||
|
| your application ready for upcoming major versions of dependencies.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'deprecations' => [
|
||||||
|
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||||
|
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log Channels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the log channels for your application. Laravel
|
||||||
|
| utilizes the Monolog PHP logging library, which includes a variety
|
||||||
|
| of powerful log handlers and formatters that you're free to use.
|
||||||
|
|
|
||||||
|
| Available drivers: "single", "daily", "slack", "syslog",
|
||||||
|
| "errorlog", "monolog", "custom", "stack"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'channels' => [
|
||||||
|
|
||||||
|
'stack' => [
|
||||||
|
'driver' => 'stack',
|
||||||
|
'channels' => explode(',', env('LOG_STACK', 'single')),
|
||||||
|
'ignore_exceptions' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'single' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'daily' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'days' => env('LOG_DAILY_DAYS', 14),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'driver' => 'slack',
|
||||||
|
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||||
|
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||||
|
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||||
|
'level' => env('LOG_LEVEL', 'critical'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'papertrail' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||||
|
'handler_with' => [
|
||||||
|
'host' => env('PAPERTRAIL_URL'),
|
||||||
|
'port' => env('PAPERTRAIL_PORT'),
|
||||||
|
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||||
|
],
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'stderr' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => StreamHandler::class,
|
||||||
|
'handler_with' => [
|
||||||
|
'stream' => 'php://stderr',
|
||||||
|
],
|
||||||
|
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'syslog' => [
|
||||||
|
'driver' => 'syslog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'errorlog' => [
|
||||||
|
'driver' => 'errorlog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'handler' => NullHandler::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'emergency' => [
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Mailer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default mailer that is used to send all email
|
||||||
|
| messages unless another mailer is explicitly specified when sending
|
||||||
|
| the message. All additional mailers can be configured within the
|
||||||
|
| "mailers" array. Examples of each type of mailer are provided.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('MAIL_MAILER', 'log'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Mailer Configurations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure all of the mailers used by your application plus
|
||||||
|
| their respective settings. Several examples have been configured for
|
||||||
|
| you and you are free to add your own as your application requires.
|
||||||
|
|
|
||||||
|
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||||
|
| when delivering an email. You may specify which one you're using for
|
||||||
|
| your mailers below. You may also add additional mailers if needed.
|
||||||
|
|
|
||||||
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||||
|
| "postmark", "resend", "log", "array",
|
||||||
|
| "failover", "roundrobin"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailers' => [
|
||||||
|
|
||||||
|
'smtp' => [
|
||||||
|
'transport' => 'smtp',
|
||||||
|
'scheme' => env('MAIL_SCHEME'),
|
||||||
|
'url' => env('MAIL_URL'),
|
||||||
|
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MAIL_PORT', 2525),
|
||||||
|
'username' => env('MAIL_USERNAME'),
|
||||||
|
'password' => env('MAIL_PASSWORD'),
|
||||||
|
'timeout' => null,
|
||||||
|
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'transport' => 'ses',
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'transport' => 'postmark',
|
||||||
|
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||||
|
// 'client' => [
|
||||||
|
// 'timeout' => 5,
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'transport' => 'resend',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sendmail' => [
|
||||||
|
'transport' => 'sendmail',
|
||||||
|
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'transport' => 'log',
|
||||||
|
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'transport' => 'array',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'transport' => 'failover',
|
||||||
|
'mailers' => [
|
||||||
|
'smtp',
|
||||||
|
'log',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
'roundrobin' => [
|
||||||
|
'transport' => 'roundrobin',
|
||||||
|
'mailers' => [
|
||||||
|
'ses',
|
||||||
|
'postmark',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global "From" Address
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You may wish for all emails sent by your application to be sent from
|
||||||
|
| the same address. Here you may specify a name and address that is
|
||||||
|
| used globally for all emails that are sent by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'from' => [
|
||||||
|
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||||
|
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
202
config/permission.php
Normal file
202
config/permission.php
Normal file
|
|
@ -0,0 +1,202 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'models' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||||
|
* is often just the "Permission" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Permission model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Permission` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permission' => Spatie\Permission\Models\Permission::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||||
|
* is often just the "Role" model but you may use whatever you like.
|
||||||
|
*
|
||||||
|
* The model you want to use as a Role model needs to implement the
|
||||||
|
* `Spatie\Permission\Contracts\Role` contract.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role' => Spatie\Permission\Models\Role::class,
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'table_names' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'roles' => 'roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your permissions. We have chosen a basic
|
||||||
|
* default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'permissions' => 'permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasPermissions" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_permissions' => 'model_has_permissions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your models roles. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_has_roles' => 'model_has_roles',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the "HasRoles" trait from this package, we need to know which
|
||||||
|
* table should be used to retrieve your roles permissions. We have chosen a
|
||||||
|
* basic default value but you may easily change it to any table you like.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'role_has_permissions' => 'role_has_permissions',
|
||||||
|
],
|
||||||
|
|
||||||
|
'column_names' => [
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related pivots other than defaults
|
||||||
|
*/
|
||||||
|
'role_pivot_key' => null, // default 'role_id',
|
||||||
|
'permission_pivot_key' => null, // default 'permission_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to name the related model primary key other than
|
||||||
|
* `model_id`.
|
||||||
|
*
|
||||||
|
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||||
|
* that case, name this `model_uuid`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_morph_key' => 'model_id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Change this if you want to use the teams feature and your related model's
|
||||||
|
* foreign key is other than `team_id`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'team_foreign_key' => 'team_id',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the method for checking permissions will be registered on the gate.
|
||||||
|
* Set this to false if you want to implement custom logic for checking permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'register_permission_check_method' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered
|
||||||
|
* this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated
|
||||||
|
* NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it.
|
||||||
|
*/
|
||||||
|
'register_octane_reset_listener' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Events will fire when a role or permission is assigned/unassigned:
|
||||||
|
* \Spatie\Permission\Events\RoleAttached
|
||||||
|
* \Spatie\Permission\Events\RoleDetached
|
||||||
|
* \Spatie\Permission\Events\PermissionAttached
|
||||||
|
* \Spatie\Permission\Events\PermissionDetached
|
||||||
|
*
|
||||||
|
* To enable, set to true, and then create listeners to watch these events.
|
||||||
|
*/
|
||||||
|
'events_enabled' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Teams Feature.
|
||||||
|
* When set to true the package implements teams using the 'team_foreign_key'.
|
||||||
|
* If you want the migrations to register the 'team_foreign_key', you must
|
||||||
|
* set this to true before doing the migration.
|
||||||
|
* If you already did the migration then you must make a new migration to also
|
||||||
|
* add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions'
|
||||||
|
* (view the latest version of this package's migration file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
'teams' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use to resolve the permissions team id
|
||||||
|
*/
|
||||||
|
'team_resolver' => \Spatie\Permission\DefaultTeamResolver::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passport Client Credentials Grant
|
||||||
|
* When set to true the package will use Passports Client to check permissions
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use_passport_client_credentials' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required permission names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_permission_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When set to true, the required role names are added to exception messages.
|
||||||
|
* This could be considered an information leak in some contexts, so the default
|
||||||
|
* setting is false here for optimum safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'display_role_in_exception' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default wildcard permission lookups are disabled.
|
||||||
|
* See documentation to understand supported syntax.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enable_wildcard_permission' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The class to use for interpreting wildcard permissions.
|
||||||
|
* If you need to modify delimiters, override the class and specify its name here.
|
||||||
|
*/
|
||||||
|
// 'wildcard_permission' => Spatie\Permission\WildcardPermission::class,
|
||||||
|
|
||||||
|
/* Cache-specific settings */
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default all permissions are cached for 24 hours to speed up performance.
|
||||||
|
* When permissions or roles are updated the cache is flushed automatically.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The cache key used to store all permissions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => 'spatie.permission.cache',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You may optionally indicate a specific cache driver to use for permission and
|
||||||
|
* role caching using any of the `store` drivers listed in the cache.php config
|
||||||
|
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => 'default',
|
||||||
|
],
|
||||||
|
];
|
||||||
112
config/queue.php
Normal file
112
config/queue.php
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Queue Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Laravel's queue supports a variety of backends via a single, unified
|
||||||
|
| API, giving you convenient access to each backend using identical
|
||||||
|
| syntax for each. The default queue connection is defined below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queue Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the connection options for every queue backend
|
||||||
|
| used by your application. An example configuration is provided for
|
||||||
|
| each backend supported by Laravel. You're also free to add more.
|
||||||
|
|
|
||||||
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sync' => [
|
||||||
|
'driver' => 'sync',
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||||
|
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||||
|
'queue' => env('DB_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'beanstalkd' => [
|
||||||
|
'driver' => 'beanstalkd',
|
||||||
|
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||||
|
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => 0,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqs' => [
|
||||||
|
'driver' => 'sqs',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||||
|
'queue' => env('SQS_QUEUE', 'default'),
|
||||||
|
'suffix' => env('SQS_SUFFIX'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||||
|
'queue' => env('REDIS_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => null,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Job Batching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following options configure the database and table that store job
|
||||||
|
| batching information. These options can be updated to any database
|
||||||
|
| connection and table which has been defined by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'batching' => [
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'job_batches',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Failed Queue Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These options configure the behavior of failed queue job logging so you
|
||||||
|
| can control how and where failed jobs are stored. Laravel ships with
|
||||||
|
| support for storing failed jobs in a simple file or in a database.
|
||||||
|
|
|
||||||
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => [
|
||||||
|
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'failed_jobs',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
84
config/sanctum.php
Normal file
84
config/sanctum.php
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Stateful Domains
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Requests from the following domains / hosts will receive stateful API
|
||||||
|
| authentication cookies. Typically, these should include your local
|
||||||
|
| and production domains which access your API via a frontend SPA.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||||
|
'%s%s',
|
||||||
|
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||||
|
Sanctum::currentApplicationUrlWithPort(),
|
||||||
|
// Sanctum::currentRequestHost(),
|
||||||
|
))),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Sanctum Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This array contains the authentication guards that will be checked when
|
||||||
|
| Sanctum is trying to authenticate a request. If none of these guards
|
||||||
|
| are able to authenticate the request, Sanctum will use the bearer
|
||||||
|
| token that's present on an incoming request for authentication.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guard' => ['web'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expiration Minutes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value controls the number of minutes until an issued token will be
|
||||||
|
| considered expired. This will override any values set in the token's
|
||||||
|
| "expires_at" attribute, but first-party sessions are not affected.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'expiration' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Token Prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||||
|
| security scanning initiatives maintained by open source platforms
|
||||||
|
| that notify developers if they commit tokens into repositories.
|
||||||
|
|
|
||||||
|
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Sanctum Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When authenticating your first-party SPA with Sanctum you may need to
|
||||||
|
| customize some of the middleware Sanctum uses while processing the
|
||||||
|
| request. You may change the middleware listed below as required.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'middleware' => [
|
||||||
|
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||||
|
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||||
|
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
38
config/services.php
Normal file
38
config/services.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Third Party Services
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is for storing the credentials for third party services such
|
||||||
|
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||||
|
| location for this type of information, allowing packages to have
|
||||||
|
| a conventional file to locate the various service credentials.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'token' => env('POSTMARK_TOKEN'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'key' => env('RESEND_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'notifications' => [
|
||||||
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
217
config/session.php
Normal file
217
config/session.php
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Session Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines the default session driver that is utilized for
|
||||||
|
| incoming requests. Laravel supports a variety of storage options to
|
||||||
|
| persist session data. Database storage is a great default choice.
|
||||||
|
|
|
||||||
|
| Supported: "file", "cookie", "database", "memcached",
|
||||||
|
| "redis", "dynamodb", "array"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('SESSION_DRIVER', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Lifetime
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the number of minutes that you wish the session
|
||||||
|
| to be allowed to remain idle before it expires. If you want them
|
||||||
|
| to expire immediately when the browser is closed then you may
|
||||||
|
| indicate that via the expire_on_close configuration option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
|
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Encryption
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option allows you to easily specify that all of your session data
|
||||||
|
| should be encrypted before it's stored. All encryption is performed
|
||||||
|
| automatically by Laravel and you may use the session like normal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session File Location
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the "file" session driver, the session files are placed
|
||||||
|
| on disk. The default storage location is defined here; however, you
|
||||||
|
| are free to provide another location where they should be stored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'files' => storage_path('framework/sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" or "redis" session drivers, you may specify a
|
||||||
|
| connection that should be used to manage these sessions. This should
|
||||||
|
| correspond to a connection in your database configuration options.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('SESSION_CONNECTION'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" session driver, you may specify the table to
|
||||||
|
| be used to store sessions. Of course, a sensible default is defined
|
||||||
|
| for you; however, you're welcome to change this to another table.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'table' => env('SESSION_TABLE', 'sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using one of the framework's cache driven session backends, you may
|
||||||
|
| define the cache store which should be used to store the session data
|
||||||
|
| between requests. This must match one of your defined cache stores.
|
||||||
|
|
|
||||||
|
| Affects: "dynamodb", "memcached", "redis"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => env('SESSION_STORE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Sweeping Lottery
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Some session drivers must manually sweep their storage location to get
|
||||||
|
| rid of old sessions from storage. Here are the chances that it will
|
||||||
|
| happen on a given request. By default, the odds are 2 out of 100.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lottery' => [2, 100],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the name of the session cookie that is created by
|
||||||
|
| the framework. Typically, you should not need to change this value
|
||||||
|
| since doing so does not grant a meaningful security improvement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cookie' => env(
|
||||||
|
'SESSION_COOKIE',
|
||||||
|
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||||
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The session cookie path determines the path for which the cookie will
|
||||||
|
| be regarded as available. Typically, this will be the root path of
|
||||||
|
| your application, but you're free to change this when necessary.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => env('SESSION_PATH', '/'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the domain and subdomains the session cookie is
|
||||||
|
| available to. By default, the cookie will be available to the root
|
||||||
|
| domain and all subdomains. Typically, this shouldn't be changed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'domain' => env('SESSION_DOMAIN'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTPS Only Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By setting this option to true, session cookies will only be sent back
|
||||||
|
| to the server if the browser has a HTTPS connection. This will keep
|
||||||
|
| the cookie from being sent to you when it can't be done securely.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTP Access Only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will prevent JavaScript from accessing the
|
||||||
|
| value of the cookie and the cookie will only be accessible through
|
||||||
|
| the HTTP protocol. It's unlikely you should disable this option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Same-Site Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines how your cookies behave when cross-site requests
|
||||||
|
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||||
|
| will set this value to "lax" to permit secure cross-site requests.
|
||||||
|
|
|
||||||
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||||
|
|
|
||||||
|
| Supported: "lax", "strict", "none", null
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Partitioned Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will tie the cookie to the top-level site for
|
||||||
|
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||||
|
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||||
|
|
||||||
|
];
|
||||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
*.sqlite*
|
||||||
44
database/factories/UserFactory.php
Normal file
44
database/factories/UserFactory.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The current password being used by the factory.
|
||||||
|
*/
|
||||||
|
protected static ?string $password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => fake()->name(),
|
||||||
|
'email' => fake()->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*/
|
||||||
|
public function unverified(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (array $attributes) => [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('users', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
|
$table->string('password');
|
||||||
|
$table->rememberToken();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||||
|
$table->string('email')->primary();
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
|
$table->string('id')->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->string('ip_address', 45)->nullable();
|
||||||
|
$table->text('user_agent')->nullable();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->integer('last_activity')->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('users');
|
||||||
|
Schema::dropIfExists('password_reset_tokens');
|
||||||
|
Schema::dropIfExists('sessions');
|
||||||
|
}
|
||||||
|
};
|
||||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('cache', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->mediumText('value');
|
||||||
|
$table->integer('expiration');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('cache_locks', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->string('owner');
|
||||||
|
$table->integer('expiration');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cache');
|
||||||
|
Schema::dropIfExists('cache_locks');
|
||||||
|
}
|
||||||
|
};
|
||||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('jobs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('queue')->index();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->unsignedTinyInteger('attempts');
|
||||||
|
$table->unsignedInteger('reserved_at')->nullable();
|
||||||
|
$table->unsignedInteger('available_at');
|
||||||
|
$table->unsignedInteger('created_at');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('job_batches', function (Blueprint $table) {
|
||||||
|
$table->string('id')->primary();
|
||||||
|
$table->string('name');
|
||||||
|
$table->integer('total_jobs');
|
||||||
|
$table->integer('pending_jobs');
|
||||||
|
$table->integer('failed_jobs');
|
||||||
|
$table->longText('failed_job_ids');
|
||||||
|
$table->mediumText('options')->nullable();
|
||||||
|
$table->integer('cancelled_at')->nullable();
|
||||||
|
$table->integer('created_at');
|
||||||
|
$table->integer('finished_at')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('uuid')->unique();
|
||||||
|
$table->text('connection');
|
||||||
|
$table->text('queue');
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->longText('exception');
|
||||||
|
$table->timestamp('failed_at')->useCurrent();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('jobs');
|
||||||
|
Schema::dropIfExists('job_batches');
|
||||||
|
Schema::dropIfExists('failed_jobs');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('soggetti', function (Blueprint $table) {
|
||||||
|
$table->id('id_soggetto');
|
||||||
|
$table->integer('old_id')->nullable()->unique()->comment('ID dal vecchio gestionale');
|
||||||
|
$table->string('nome')->nullable();
|
||||||
|
$table->string('cognome')->nullable();
|
||||||
|
$table->string('ragione_sociale')->nullable();
|
||||||
|
$table->string('codice_fiscale', 16)->nullable()->index();
|
||||||
|
$table->string('partita_iva', 11)->nullable()->index();
|
||||||
|
$table->string('email')->nullable()->index();
|
||||||
|
$table->string('telefono')->nullable();
|
||||||
|
$table->string('indirizzo')->nullable();
|
||||||
|
$table->string('cap', 10)->nullable();
|
||||||
|
$table->string('citta', 60)->nullable();
|
||||||
|
$table->string('provincia', 2)->nullable();
|
||||||
|
$table->enum('tipo', ['proprietario', 'inquilino', 'usufruttuario', 'altro']);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('soggetti');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('amministratori', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_amministratore'); // Chiave primaria corretta
|
||||||
|
$table->string('nome');
|
||||||
|
$table->string('cognome');
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('denominazione_studio')->nullable();
|
||||||
|
$table->string('partita_iva')->nullable()->unique(); // Assicurati che sia unica se necessario
|
||||||
|
$table->string('codice_fiscale_studio')->nullable();
|
||||||
|
$table->string('indirizzo_studio')->nullable();
|
||||||
|
$table->string('cap_studio', 10)->nullable();
|
||||||
|
$table->string('citta_studio', 60)->nullable();
|
||||||
|
$table->string('provincia_studio', 2)->nullable();
|
||||||
|
$table->string('telefono_studio')->nullable();
|
||||||
|
$table->string('email_studio')->nullable();
|
||||||
|
$table->string('pec_studio')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('amministratori');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('stabili', function (Blueprint $table) {
|
||||||
|
$table->id('id_stabile');
|
||||||
|
$table->unsignedBigInteger('amministratore_id');
|
||||||
|
$table->string('denominazione');
|
||||||
|
$table->string('indirizzo');
|
||||||
|
$table->string('cap', 10);
|
||||||
|
$table->string('citta', 60);
|
||||||
|
$table->string('provincia', 2);
|
||||||
|
$table->string('codice_fiscale', 20)->nullable()->unique();
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->json('rate_ordinarie_mesi')->nullable();
|
||||||
|
$table->json('rate_riscaldamento_mesi')->nullable();
|
||||||
|
$table->text('descrizione_rate')->nullable();
|
||||||
|
$table->string('stato', 50)->default('attivo');
|
||||||
|
$table->integer('old_id')->nullable()->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreign('amministratore_id')->references('id_amministratore')->on('amministratori')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('stabili');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('unita_immobiliari', function (Blueprint $table) {
|
||||||
|
$table->id('id_unita');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->string('fabbricato')->nullable();
|
||||||
|
$table->string('interno')->nullable();
|
||||||
|
$table->string('scala')->nullable();
|
||||||
|
$table->string('piano')->nullable();
|
||||||
|
$table->string('subalterno')->nullable();
|
||||||
|
$table->string('categoria_catastale', 10)->nullable();
|
||||||
|
$table->decimal('superficie', 8, 2)->nullable();
|
||||||
|
$table->decimal('vani', 5, 2)->nullable();
|
||||||
|
$table->string('indirizzo')->nullable()->comment('Indirizzo specifico se diverso da quello del condominio');
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('unita_immobiliari');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('proprieta', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('unita_immobiliare_id')->constrained('unita_immobiliari', 'id_unita')->onDelete('cascade');
|
||||||
|
$table->foreignId('soggetto_id')->constrained('soggetti', 'id_soggetto')->onDelete('cascade');
|
||||||
|
$table->enum('tipo_diritto', ['proprietario', 'nudo_proprietario', 'usufruttuario', 'inquilino', 'comodatario', 'altro']);
|
||||||
|
$table->decimal('percentuale_possesso', 5, 2)->nullable();
|
||||||
|
$table->date('data_inizio')->nullable();
|
||||||
|
$table->date('data_fine')->nullable();
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('proprieta');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->morphs('tokenable');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('token', 64)->unique();
|
||||||
|
$table->text('abilities')->nullable();
|
||||||
|
$table->timestamp('last_used_at')->nullable();
|
||||||
|
$table->timestamp('expires_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('personal_access_tokens');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('fornitori', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_fornitore');
|
||||||
|
$table->integer('old_id')->nullable()->unique()->comment('ID dal vecchio gestionale');
|
||||||
|
$table->foreignId('amministratore_id')->constrained(table: 'amministratori', column: 'id_amministratore')->onDelete('cascade');
|
||||||
|
$table->string('ragione_sociale');
|
||||||
|
$table->string('partita_iva', 20)->nullable();
|
||||||
|
$table->string('codice_fiscale', 20)->nullable();
|
||||||
|
$table->string('indirizzo')->nullable();
|
||||||
|
$table->string('cap', 10)->nullable();
|
||||||
|
$table->string('citta', 60)->nullable();
|
||||||
|
$table->string('provincia', 2)->nullable();
|
||||||
|
$table->string('email')->nullable();
|
||||||
|
$table->string('pec')->nullable();
|
||||||
|
$table->string('telefono')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('fornitori'); // Già corretto, ma confermo
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('categorie_ticket', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('nome')->unique();
|
||||||
|
$table->text('descrizione')->nullable();
|
||||||
|
// Potresti aggiungere foreign key per assegnatari/fornitori di default
|
||||||
|
// $table->foreignId('default_user_id')->nullable()->constrained('users')->onDelete('set null');
|
||||||
|
// $table->foreignId('default_fornitore_id')->nullable()->constrained('fornitori')->onDelete('set null');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categorie_ticket');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('tickets', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('stabile_id')->constrained(table: 'stabili', column: 'id_stabile')->onDelete('cascade');
|
||||||
|
$table->foreignId('unita_immobiliare_id')->nullable()->constrained(table: 'unita_immobiliari', column: 'id_unita')->onDelete('set null');
|
||||||
|
$table->foreignId('soggetto_richiedente_id')->nullable()->constrained(table: 'soggetti', column: 'id_soggetto')->onDelete('set null');
|
||||||
|
$table->foreignId('aperto_da_user_id')->comment('Utente che ha aperto il ticket')->constrained('users')->onDelete('cascade');
|
||||||
|
$table->foreignId('categoria_ticket_id')->nullable()->constrained(table: 'categorie_ticket', column: 'id')->onDelete('set null');
|
||||||
|
$table->string('titolo');
|
||||||
|
$table->text('descrizione');
|
||||||
|
$table->string('luogo_intervento')->nullable()->comment('Es. Scala A, Piano 3, Interno 5');
|
||||||
|
|
||||||
|
$table->enum('stato', [
|
||||||
|
'Aperto', 'Preso in Carico', 'In Lavorazione', 'In Attesa Approvazione',
|
||||||
|
'In Attesa Ricambi', 'Risolto', 'Chiuso', 'Annullato'
|
||||||
|
])->default('Aperto');
|
||||||
|
$table->enum('priorita', ['Bassa', 'Media', 'Alta', 'Urgente'])->default('Media');
|
||||||
|
|
||||||
|
$table->foreignId('assegnato_a_user_id')->nullable()->comment('Utente interno (manutentore/collaboratore)')->constrained('users')->onDelete('set null'); // Utente del sistema a cui è assegnato
|
||||||
|
$table->foreignId('assegnato_a_fornitore_id')->nullable()->constrained(table: 'fornitori', column: 'id_fornitore')->onDelete('set null'); // Fornitore esterno assegnato
|
||||||
|
|
||||||
|
$table->timestamp('data_apertura')->useCurrent();
|
||||||
|
$table->date('data_scadenza_prevista')->nullable();
|
||||||
|
$table->timestamp('data_risoluzione_effettiva')->nullable();
|
||||||
|
$table->timestamp('data_chiusura_effettiva')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps(); // created_at, updated_at
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tickets');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ticket_updates', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('ticket_id')->constrained('tickets')->onDelete('cascade');
|
||||||
|
$table->foreignId('user_id')->nullable()->comment('Utente che ha fatto l\'aggiornamento')->constrained('users')->onDelete('set null');
|
||||||
|
$table->text('update_text')->comment('Testo dell\'aggiornamento o nota interna');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ticket_updates');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ticket_messages', function (Blueprint $table) {
|
||||||
|
$table->id(); // Chiave primaria
|
||||||
|
$table->foreignId('ticket_id')->constrained('tickets')->onDelete('cascade'); // Ticket a cui appartiene il messaggio
|
||||||
|
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('set null'); // Utente che ha scritto il messaggio (se loggato)
|
||||||
|
$table->text('messaggio'); // Contenuto del messaggio
|
||||||
|
$table->timestamps(); // Include created_at (data invio)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ticket_messages');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ticket_attachments', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
// Un allegato può essere legato direttamente al ticket o a un suo aggiornamento
|
||||||
|
$table->foreignId('ticket_id')->constrained('tickets')->onDelete('cascade');
|
||||||
|
$table->foreignId('ticket_update_id')->nullable()->constrained('ticket_updates')->onDelete('cascade');
|
||||||
|
$table->foreignId('user_id')->comment('Utente che ha caricato l allegato')->constrained('users')->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->string('file_path');
|
||||||
|
$table->string('original_file_name');
|
||||||
|
$table->string('mime_type')->nullable();
|
||||||
|
$table->unsignedBigInteger('size')->nullable()->comment('Dimensione in bytes');
|
||||||
|
$table->string('description')->nullable(); // Descrizione opzionale dell'allegato
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ticket_attachments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('conti_condominio', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_conto_condominio');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->string('codice_conto', 50)->nullable()->unique();
|
||||||
|
$table->string('nome_conto');
|
||||||
|
$table->string('iban', 34)->nullable()->unique();
|
||||||
|
$table->string('bic_swift', 11)->nullable();
|
||||||
|
$table->string('nome_banca')->nullable();
|
||||||
|
$table->string('filiale_banca')->nullable();
|
||||||
|
$table->string('tipo_conto', 50)->comment('Es. BANCARIO, CASSA, PAYPAL');
|
||||||
|
$table->decimal('saldo_iniziale', 15, 2)->default(0.00);
|
||||||
|
$table->date('data_saldo_iniziale');
|
||||||
|
$table->string('valuta', 3)->default('EUR');
|
||||||
|
$table->boolean('attivo')->default(true);
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('conti_condominio');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('tabelle_millesimali', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_tabella_millesimale');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->string('nome_tabella', 100);
|
||||||
|
$table->text('descrizione')->nullable();
|
||||||
|
$table->string('tipo_tabella', 50)->nullable();
|
||||||
|
$table->decimal('totale_millesimi_teorico', 10, 4)->default(1000.0000);
|
||||||
|
$table->boolean('attiva')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
$table->unique(['id_stabile', 'nome_tabella']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tabelle_millesimali');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('dettagli_tabelle_millesimali', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_dettaglio_millesimale');
|
||||||
|
$table->unsignedBigInteger('id_tabella_millesimale');
|
||||||
|
$table->unsignedBigInteger('id_unita');
|
||||||
|
$table->decimal('valore_millesimale', 10, 4);
|
||||||
|
$table->decimal('coefficiente_correttivo', 8, 4)->default(1.0000);
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->foreign('id_tabella_millesimale')->references('id_tabella_millesimale')->on('tabelle_millesimali')->onDelete('cascade');
|
||||||
|
$table->foreign('id_unita')->references('id_unita')->on('unita_immobiliari')->onDelete('cascade');
|
||||||
|
$table->unique(['id_tabella_millesimale', 'id_unita'], 'dett_milles_tab_unita_unique');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('dettagli_tabelle_millesimali');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('allegati', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_allegato');
|
||||||
|
$table->unsignedBigInteger('id_stabile')->nullable(); // Per scope e pulizia
|
||||||
|
$table->string('nome_file_originale');
|
||||||
|
$table->string('nome_file_storage')->unique();
|
||||||
|
$table->text('percorso_file_storage');
|
||||||
|
$table->string('tipo_mime', 100);
|
||||||
|
$table->bigInteger('dimensione_byte')->unsigned();
|
||||||
|
$table->text('descrizione')->nullable();
|
||||||
|
$table->unsignedBigInteger('allegabile_id'); // ID del record a cui è allegato
|
||||||
|
$table->string('allegabile_type', 100); // Nome della tabella/entità
|
||||||
|
$table->unsignedBigInteger('id_utente_caricamento')->nullable(); // Chi ha caricato
|
||||||
|
$table->string('tags')->nullable();
|
||||||
|
$table->index(['allegabile_id', 'allegabile_type']);
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('set null');
|
||||||
|
// Potresti aggiungere una foreign key per id_utente_caricamento se hai una tabella utenti
|
||||||
|
// $table->foreign('id_utente_caricamento')->references('id')->on('users')->onDelete('set null');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('allegati');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('gestioni', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_gestione');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->integer('anno');
|
||||||
|
$table->enum('tipo', ['ORDINARIA', 'RISCALDAMENTO', 'STRAORDINARIA']);
|
||||||
|
$table->date('data_inizio');
|
||||||
|
$table->date('data_fine');
|
||||||
|
$table->enum('stato', ['aperta', 'chiusa'])->default('aperta');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
$table->unique(['id_stabile', 'anno', 'tipo'], 'unique_gestione_per_stabile_anno_tipo');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('gestioni');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('voci_spesa', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_voce');
|
||||||
|
$table->string('codice')->nullable()->unique();
|
||||||
|
$table->string('descrizione');
|
||||||
|
$table->string('tipo', 50)->nullable()->comment('ordinaria/straordinaria/riscaldamento/altro');
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('voci_spesa');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Questo file crea la tabella 'voci_spesa' per gestire le voci di spesa nel gestionale.
|
||||||
|
// La tabella include:
|
||||||
|
// - id_voce: ID univoco della voce di spesa
|
||||||
|
// - codice: Codice univoco della voce di spesa
|
||||||
|
// - descrizione: Descrizione della voce di spesa
|
||||||
|
// - tipo: Tipo di spesa (ordinaria, straordinaria, riscaldamento, altro)
|
||||||
|
// - note: Note aggiuntive sulla voce di spesa
|
||||||
|
// - timestamps: Campi created_at e updated_at per la gestione delle date
|
||||||
|
//
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('piani_conti_modello', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_conto_modello');
|
||||||
|
$table->string('codice', 20)->unique();
|
||||||
|
$table->string('descrizione');
|
||||||
|
$table->string('tipo_conto', 50)->comment('Es. PATRIMONIALE_ATTIVITA, ECONOMICO_COSTO, FINANZIARIO_ATTIVITA');
|
||||||
|
$table->string('natura_saldo_tipico', 5)->nullable()->comment('DARE o AVERE');
|
||||||
|
$table->boolean('is_conto_finanziario')->default(false);
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('piani_conti_modello');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('piano_conti_condominio', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_conto_condominio_pc');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->unsignedBigInteger('id_conto_modello_riferimento')->nullable();
|
||||||
|
$table->string('codice', 20);
|
||||||
|
$table->string('descrizione');
|
||||||
|
$table->string('tipo_conto', 50);
|
||||||
|
$table->string('natura_saldo_tipico', 5)->nullable();
|
||||||
|
$table->boolean('is_conto_finanziario')->default(false);
|
||||||
|
$table->boolean('attivo')->default(true);
|
||||||
|
$table->text('note')->nullable();
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
$table->foreign('id_conto_modello_riferimento')->references('id_conto_modello')->on('piani_conti_modello')->onDelete('set null');
|
||||||
|
$table->unique(['id_stabile', 'codice']);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('piano_conti_condominio');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('transazioni_contabili', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_transazione');
|
||||||
|
$table->unsignedBigInteger('id_stabile');
|
||||||
|
$table->unsignedBigInteger('id_gestione')->nullable();
|
||||||
|
$table->date('data_registrazione');
|
||||||
|
$table->date('data_documento')->nullable();
|
||||||
|
$table->date('data_competenza')->nullable();
|
||||||
|
$table->string('numero_protocollo_interno', 50)->nullable(); // Rimosso il vincolo unique
|
||||||
|
$table->string('tipo_documento_origine', 100)->nullable();
|
||||||
|
$table->string('riferimento_documento_esterno')->nullable();
|
||||||
|
$table->text('descrizione_generale')->nullable();
|
||||||
|
$table->decimal('importo_totale_transazione', 15, 2)->nullable(); // Può essere calcolato
|
||||||
|
$table->string('stato_transazione', 50)->default('PROVVISORIA');
|
||||||
|
$table->unsignedBigInteger('id_utente_registrazione')->nullable(); // Chi ha registrato
|
||||||
|
$table->foreign('id_stabile')->references('id_stabile')->on('stabili')->onDelete('cascade');
|
||||||
|
$table->foreign('id_gestione')->references('id_gestione')->on('gestioni')->onDelete('set null');
|
||||||
|
// Potresti aggiungere una foreign key per id_utente_registrazione
|
||||||
|
// $table->foreign('id_utente_registrazione')->references('id')->on('users')->onDelete('set null');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('transazioni_contabili');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('righe_movimenti_contabili', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id_riga_movimento');
|
||||||
|
$table->unsignedBigInteger('id_transazione');
|
||||||
|
$table->unsignedBigInteger('id_piano_conto_condominio_pc');
|
||||||
|
$table->unsignedBigInteger('id_gestione_imputazione')->nullable(); // Gestione specifica per la riga
|
||||||
|
$table->text('descrizione_riga')->nullable();
|
||||||
|
$table->decimal('importo_dare', 15, 2)->default(0.00);
|
||||||
|
$table->decimal('importo_avere', 15, 2)->default(0.00);
|
||||||
|
$table->unsignedBigInteger('id_unita_immobiliare')->nullable();
|
||||||
|
$table->unsignedBigInteger('id_soggetto')->nullable();
|
||||||
|
$table->unsignedBigInteger('id_fornitore')->nullable();
|
||||||
|
$table->unsignedBigInteger('id_voce_spesa_originale')->nullable(); // Per compatibilità/import
|
||||||
|
$table->text('note_riga')->nullable();
|
||||||
|
$table->foreign('id_transazione')->references('id_transazione')->on('transazioni_contabili')->onDelete('cascade');
|
||||||
|
$table->foreign('id_piano_conto_condominio_pc')->references('id_conto_condominio_pc')->on('piano_conti_condominio')->onDelete('restrict'); // Non eliminare un conto se usato
|
||||||
|
$table->foreign('id_gestione_imputazione')->references('id_gestione')->on('gestioni')->onDelete('set null');
|
||||||
|
$table->foreign('id_unita_immobiliare')->references('id_unita')->on('unita_immobiliari')->onDelete('set null');
|
||||||
|
$table->foreign('id_soggetto')->references('id_soggetto')->on('soggetti')->onDelete('set null');
|
||||||
|
$table->foreign('id_fornitore')->references('id_fornitore')->on('fornitori')->onDelete('set null');
|
||||||
|
$table->foreign('id_voce_spesa_originale')->references('id_voce')->on('voci_spesa')->onDelete('set null');
|
||||||
|
|
||||||
|
$table->index('id_piano_conto_condominio_pc');
|
||||||
|
$table->index('id_gestione_imputazione');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('righe_movimenti_contabili');
|
||||||
|
}
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user