Initial commit - construprogress app
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
[compose.yaml]
|
||||||
|
indent_size = 4
|
||||||
@@ -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=sqlite
|
||||||
|
# DB_HOST=127.0.0.1
|
||||||
|
# DB_PORT=3306
|
||||||
|
# DB_DATABASE=laravel
|
||||||
|
# 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}"
|
||||||
@@ -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
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
*.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/pail
|
||||||
|
/vendor
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
Thumbs.db
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<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 can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||||
|
|
||||||
|
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).
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use App\Services\SpatialFileConverter;
|
||||||
|
use App\Models\Phase;
|
||||||
|
|
||||||
|
class ConvertSpatialFile extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected $signature = 'convert:spatial {file} {phase_id}';
|
||||||
|
protected $description = 'Convert a spatial file (DWG, SHP, KML, GeoJSON) to GeoJSON and attach to phase';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$filePath = $this->argument('file');
|
||||||
|
$phaseId = $this->argument('phase_id');
|
||||||
|
$phase = Phase::findOrFail($phaseId);
|
||||||
|
$file = new \Illuminate\Http\UploadedFile($filePath, basename($filePath));
|
||||||
|
|
||||||
|
$geojson = SpatialFileConverter::convertToGeoJson($file, $file->getClientOriginalName());
|
||||||
|
if ($geojson) {
|
||||||
|
$layer = $phase->layers()->create([
|
||||||
|
'project_id' => $phase->project_id,
|
||||||
|
'name' => 'Converted: ' . basename($filePath),
|
||||||
|
'geojson_data' => $geojson,
|
||||||
|
'uploaded_by' => 1, // admin
|
||||||
|
'original_file' => $filePath
|
||||||
|
]);
|
||||||
|
$this->info("GeoJSON saved to layer ID {$layer->id}");
|
||||||
|
} else {
|
||||||
|
$this->error("Conversion failed for file type.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Layer;
|
||||||
|
use App\Models\Feature;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class MigrateGeojsonToFeatures extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'migrate:geojson-to-features';
|
||||||
|
protected $description = 'Migrate features from layer.geojson_data to features table';
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$layers = Layer::whereNotNull('geojson_data')->get();
|
||||||
|
$totalFeatures = 0;
|
||||||
|
|
||||||
|
foreach ($layers as $layer) {
|
||||||
|
$geojson = $layer->geojson_data;
|
||||||
|
if (!isset($geojson['features'])) continue;
|
||||||
|
|
||||||
|
foreach ($geojson['features'] as $featureData) {
|
||||||
|
$geometry = $featureData['geometry'];
|
||||||
|
$props = $featureData['properties'] ?? [];
|
||||||
|
|
||||||
|
Feature::create([
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'name' => $props['name'] ?? null,
|
||||||
|
'geometry' => $geometry,
|
||||||
|
'properties' => $props,
|
||||||
|
'template_id' => $props['template_id'] ?? null,
|
||||||
|
'progress' => $props['progress'] ?? 0,
|
||||||
|
'responsible' => $props['responsible'] ?? null,
|
||||||
|
]);
|
||||||
|
$totalFeatures++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Opcional: Marcar la capa como migrada (podrías agregar columna 'migrated_at')
|
||||||
|
$this->info("Layer {$layer->id} ({$layer->name}) migrated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Total features migrated: {$totalFeatures}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
abstract class Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\features;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class FeaturesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(features $features)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(features $features)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, features $features)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(features $features)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\PendingSync;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class OfflineSyncController extends Controller
|
||||||
|
{
|
||||||
|
public function storePending(Request $request)
|
||||||
|
{
|
||||||
|
$payload = $request->validate([
|
||||||
|
'action' => 'required|in:progress_update,task_complete',
|
||||||
|
'payload' => 'required|array',
|
||||||
|
]);
|
||||||
|
$pending = PendingSync::create([
|
||||||
|
'user_id' => Auth::id() ?? 1,
|
||||||
|
'action' => $payload['action'],
|
||||||
|
'payload' => $payload['payload'],
|
||||||
|
]);
|
||||||
|
return response()->json(['queued' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sync(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$pendings = PendingSync::where('user_id', $user->id)->whereNull('synced_at')->get();
|
||||||
|
foreach ($pendings as $pending) {
|
||||||
|
if ($pending->action === 'progress_update') {
|
||||||
|
$phase = Phase::find($pending->payload['phase_id']);
|
||||||
|
if ($phase) {
|
||||||
|
$phase->progress_percent = $pending->payload['progress'];
|
||||||
|
$phase->save();
|
||||||
|
$phase->progressUpdates()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'progress_percent' => $pending->payload['progress'],
|
||||||
|
'comment' => $pending->payload['comment'] ?? '',
|
||||||
|
'location' => $pending->payload['location'] ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pending->synced_at = now();
|
||||||
|
$pending->save();
|
||||||
|
}
|
||||||
|
return response()->json(['synced' => count($pendings)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class ProjectController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
Gate::authorize('view projects');
|
||||||
|
return view('projects.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
Gate::authorize('create projects');
|
||||||
|
return view('projects.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
Gate::authorize('create projects');
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'address' => 'required',
|
||||||
|
'lat' => 'required|numeric',
|
||||||
|
'lng' => 'required|numeric',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date_estimated' => 'nullable|date',
|
||||||
|
]);
|
||||||
|
$project = Project::create(array_merge($validated, ['created_by' => Auth::id(), 'status' => 'planning']));
|
||||||
|
|
||||||
|
// Assign creator as supervisor in project
|
||||||
|
$project->users()->attach(Auth::id(), ['role_in_project' => 'supervisor']);
|
||||||
|
return redirect()->route('projects.map', $project)->with('success', 'Proyecto creado');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(string $id)
|
||||||
|
{
|
||||||
|
// No usamos show, redirigimos al mapa o a edición
|
||||||
|
return redirect()->route('projects.map', $project);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(Project $project) // <--- ROUTE MODEL BINDING
|
||||||
|
{
|
||||||
|
Gate::authorize('edit projects', $project);
|
||||||
|
return view('projects.edit', compact('project'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request, Project $project) // <--- ROUTE MODEL BINDING
|
||||||
|
{
|
||||||
|
Gate::authorize('edit projects', $project);
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'address' => 'required|string',
|
||||||
|
'lat' => 'required|numeric',
|
||||||
|
'lng' => 'required|numeric',
|
||||||
|
'status' => 'required|in:planning,in_progress,paused,completed',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'end_date_estimated' => 'nullable|date|after:start_date',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$project->update($validated);
|
||||||
|
|
||||||
|
return redirect()->route('projects.index')
|
||||||
|
->with('success', 'Proyecto actualizado correctamente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified project from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Project $project) // <--- ROUTE MODEL BINDING
|
||||||
|
{
|
||||||
|
Gate::authorize('delete projects', $project);
|
||||||
|
|
||||||
|
$project->delete();
|
||||||
|
|
||||||
|
return redirect()->route('projects.index')
|
||||||
|
->with('success', 'Proyecto eliminado correctamente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the map view for a specific project.
|
||||||
|
*/
|
||||||
|
public function map(Project $project)
|
||||||
|
{
|
||||||
|
// Cualquier usuario autenticado puede ver el mapa si tiene acceso al proyecto
|
||||||
|
// (lo validaremos dentro del componente Livewire)
|
||||||
|
return view('projects.map', compact('project'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Actions;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class Logout
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Log the current user out of the application.
|
||||||
|
*/
|
||||||
|
public function __invoke(): void
|
||||||
|
{
|
||||||
|
Auth::guard('web')->logout();
|
||||||
|
|
||||||
|
Session::invalidate();
|
||||||
|
Session::regenerateToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Forms;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Lockout;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Livewire\Attributes\Validate;
|
||||||
|
use Livewire\Form;
|
||||||
|
|
||||||
|
class LoginForm extends Form
|
||||||
|
{
|
||||||
|
#[Validate('required|string|email')]
|
||||||
|
public string $email = '';
|
||||||
|
|
||||||
|
#[Validate('required|string')]
|
||||||
|
public string $password = '';
|
||||||
|
|
||||||
|
#[Validate('boolean')]
|
||||||
|
public bool $remember = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to authenticate the request's credentials.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function authenticate(): void
|
||||||
|
{
|
||||||
|
$this->ensureIsNotRateLimited();
|
||||||
|
|
||||||
|
if (! Auth::attempt($this->only(['email', 'password']), $this->remember)) {
|
||||||
|
RateLimiter::hit($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'form.email' => trans('auth.failed'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::clear($this->throttleKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the authentication request is not rate limited.
|
||||||
|
*/
|
||||||
|
protected function ensureIsNotRateLimited(): void
|
||||||
|
{
|
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event(new Lockout(request()));
|
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'form.email' => trans('auth.throttle', [
|
||||||
|
'seconds' => $seconds,
|
||||||
|
'minutes' => ceil($seconds / 60),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the authentication rate limiting throttle key.
|
||||||
|
*/
|
||||||
|
protected function throttleKey(): string
|
||||||
|
{
|
||||||
|
return Str::transliterate(Str::lower($this->email).'|'.request()->ip());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use Livewire\Attributes\Layout;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use App\Models\Layer;
|
||||||
|
use App\Services\SpatialFileConverter;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
#[Layout('layouts.app')]
|
||||||
|
class LayerManager extends Component
|
||||||
|
{
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public Project $project;
|
||||||
|
public Phase $phase;
|
||||||
|
public $layers;
|
||||||
|
public $selectedLayer = null;
|
||||||
|
public $visibleLayers = []; // IDs de capas visibles
|
||||||
|
|
||||||
|
public $uploadFile = null;
|
||||||
|
public $layerName = '';
|
||||||
|
public $layerColor = '#3b82f6';
|
||||||
|
public $manualGeojson = null;
|
||||||
|
public $drawingMode = false;
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'uploadFile' => 'required|file|mimes:geojson,kmz,kml,shp,dwg,zip|max:51200',
|
||||||
|
'layerName' => 'required|string|max:255',
|
||||||
|
'layerColor' => 'nullable|string|size:7',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount(Project $project, Phase $phase)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->phase = $phase;
|
||||||
|
$this->loadLayers();
|
||||||
|
if ($this->phase->project_id !== $this->project->id) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
// Por defecto todas visibles
|
||||||
|
$this->visibleLayers = $this->layers->pluck('id')->toArray();
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadLayers()
|
||||||
|
{
|
||||||
|
$this->layers = Layer::where('phase_id', $this->phase->id)->latest()->get();
|
||||||
|
// Eliminar de visibles las que ya no existen
|
||||||
|
$this->visibleLayers = array_intersect($this->visibleLayers, $this->layers->pluck('id')->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function emitInitialLayersData()
|
||||||
|
{
|
||||||
|
$layersData = $this->layers->map(function($layer) {
|
||||||
|
return [
|
||||||
|
'id' => $layer->id,
|
||||||
|
'geojson' => $layer->geojson_data,
|
||||||
|
'color' => $layer->geojson_data['style']['color'] ?? '#3b82f6',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
$this->dispatch('initialLayersData', [
|
||||||
|
'layers' => $layersData,
|
||||||
|
'visibleLayers' => $this->visibleLayers,
|
||||||
|
'selectedLayerId' => $this->selectedLayer?->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleLayerVisibility($layerId)
|
||||||
|
{
|
||||||
|
if ($this->selectedLayer && $this->selectedLayer->id == $layerId) {
|
||||||
|
session()->flash('info', 'No puedes ocultar la capa que estás editando.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (in_array($layerId, $this->visibleLayers)) {
|
||||||
|
$this->visibleLayers = array_diff($this->visibleLayers, [$layerId]);
|
||||||
|
} else {
|
||||||
|
$this->visibleLayers[] = $layerId;
|
||||||
|
}
|
||||||
|
$this->dispatch('visibilityChanged', $this->visibleLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectLayer($layerId)
|
||||||
|
{
|
||||||
|
$this->selectedLayer = Layer::find($layerId);
|
||||||
|
if (!$this->selectedLayer) return;
|
||||||
|
// Asegurar que la capa seleccionada está visible
|
||||||
|
if (!in_array($layerId, $this->visibleLayers)) {
|
||||||
|
$this->visibleLayers[] = $layerId;
|
||||||
|
$this->dispatch('visibilityChanged', $this->visibleLayers);
|
||||||
|
}
|
||||||
|
$geojson = $this->selectedLayer->geojson_data;
|
||||||
|
$this->dispatch('layerSelectedForEdit', [
|
||||||
|
'layerId' => $layerId,
|
||||||
|
'geojson' => $geojson,
|
||||||
|
'color' => $geojson['style']['color'] ?? '#3b82f6',
|
||||||
|
]);
|
||||||
|
session()->flash('info', 'Editando capa: ' . $this->selectedLayer->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function importFile()
|
||||||
|
{
|
||||||
|
$this->validate();
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user->can('upload layers') && !$user->hasRole('Admin')) {
|
||||||
|
session()->flash('error', 'Sin permisos.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectDir = "uploads/projects/{$this->project->id}/layers";
|
||||||
|
$originalPath = $this->uploadFile->store($projectDir, 'public');
|
||||||
|
$geojson = SpatialFileConverter::convertToGeoJson($this->uploadFile);
|
||||||
|
if (!$geojson) {
|
||||||
|
session()->flash('error', 'Conversión fallida.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$geojson['style'] = ['color' => $this->layerColor ?: '#3b82f6'];
|
||||||
|
|
||||||
|
$layer = Layer::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'phase_id' => $this->phase->id,
|
||||||
|
'name' => $this->layerName,
|
||||||
|
'geojson_data' => $geojson,
|
||||||
|
'original_file' => $originalPath,
|
||||||
|
'uploaded_by' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->loadLayers();
|
||||||
|
$this->visibleLayers[] = $layer->id;
|
||||||
|
$this->reset(['uploadFile', 'layerName']);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa importada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createEmptyLayer()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$emptyGeojson = [
|
||||||
|
'type' => 'FeatureCollection',
|
||||||
|
'features' => [],
|
||||||
|
'style' => ['color' => $this->layerColor ?: '#3b82f6']
|
||||||
|
];
|
||||||
|
$layer = Layer::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'phase_id' => $this->phase->id,
|
||||||
|
'name' => $this->layerName ?: 'Nueva capa',
|
||||||
|
'geojson_data' => $emptyGeojson,
|
||||||
|
'original_file' => null,
|
||||||
|
'uploaded_by' => $user->id,
|
||||||
|
]);
|
||||||
|
$this->loadLayers();
|
||||||
|
$this->visibleLayers[] = $layer->id;
|
||||||
|
$this->selectLayer($layer->id);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa vacía creada y seleccionada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveManualGeojson($geojsonString)
|
||||||
|
{
|
||||||
|
if (!$this->selectedLayer) {
|
||||||
|
session()->flash('error', 'No hay capa seleccionada.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$geojson = json_decode($geojsonString, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
session()->flash('error', 'GeoJSON inválido.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$geojson['style'] = ['color' => $this->layerColor ?: ($this->selectedLayer->geojson_data['style']['color'] ?? '#3b82f6')];
|
||||||
|
$this->selectedLayer->geojson_data = $geojson;
|
||||||
|
$this->selectedLayer->save();
|
||||||
|
|
||||||
|
$this->loadLayers(); // recargar por si acaso
|
||||||
|
$this->selectLayer($this->selectedLayer->id);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa guardada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteLayer($layerId)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user->can('delete layers') && !$user->hasRole('Admin')) abort(403);
|
||||||
|
$layer = Layer::find($layerId);
|
||||||
|
if (!$layer) return;
|
||||||
|
if ($layer->original_file) Storage::disk('public')->delete($layer->original_file);
|
||||||
|
$layer->delete();
|
||||||
|
$this->loadLayers();
|
||||||
|
if ($this->selectedLayer && $this->selectedLayer->id == $layerId) {
|
||||||
|
$this->selectedLayer = null;
|
||||||
|
}
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa eliminada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelEditing()
|
||||||
|
{
|
||||||
|
$this->selectedLayer = null;
|
||||||
|
$this->dispatch('layerSelectedForEdit', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.layer-manager');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,307 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithFileUploads;
|
||||||
|
use Livewire\Attributes\Layout;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use App\Models\Layer;
|
||||||
|
use App\Services\SpatialFileConverter;
|
||||||
|
use App\Models\Feature;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
#[Layout('layouts.app')]
|
||||||
|
class LayerManager extends Component
|
||||||
|
{
|
||||||
|
use WithFileUploads;
|
||||||
|
|
||||||
|
public Project $project;
|
||||||
|
public Phase $phase;
|
||||||
|
public $layers;
|
||||||
|
public $selectedLayer = null;
|
||||||
|
public $visibleLayers = []; // IDs de capas visibles
|
||||||
|
|
||||||
|
public $uploadFile = null;
|
||||||
|
public $layerName = '';
|
||||||
|
public $layerColor = '#3b82f6';
|
||||||
|
public $manualGeojson = null;
|
||||||
|
public $drawingMode = false;
|
||||||
|
|
||||||
|
protected $rules = [
|
||||||
|
'uploadFile' => 'required|file|mimes:geojson,kmz,kml,shp,dwg,zip|max:51200',
|
||||||
|
'layerName' => 'required|string|max:255',
|
||||||
|
'layerColor' => 'nullable|string|size:7',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount(Project $project, Phase $phase)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->phase = $phase;
|
||||||
|
$this->loadLayers();
|
||||||
|
if ($this->phase->project_id !== $this->project->id) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
// Por defecto todas visibles
|
||||||
|
$this->visibleLayers = $this->layers->pluck('id')->toArray();
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadLayers()
|
||||||
|
{
|
||||||
|
$this->layers = Layer::with('features')->where('phase_id', $this->phase->id)->latest()->get();
|
||||||
|
$this->visibleLayers = array_intersect($this->visibleLayers, $this->layers->pluck('id')->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function emitInitialLayersData()
|
||||||
|
{
|
||||||
|
$layersData = $this->layers->map(function($layer) {
|
||||||
|
// Construir FeatureCollection a partir de los features de esta capa
|
||||||
|
$features = $layer->features->map(function($feature) {
|
||||||
|
return [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'id' => $feature->id,
|
||||||
|
'geometry' => $feature->geometry,
|
||||||
|
'properties' => [
|
||||||
|
'name' => $feature->name,
|
||||||
|
'progress' => $feature->progress,
|
||||||
|
'responsible' => $feature->responsible,
|
||||||
|
'template_id' => $feature->template_id,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
})->values()->toArray();
|
||||||
|
|
||||||
|
$geojson = [
|
||||||
|
'type' => 'FeatureCollection',
|
||||||
|
'features' => $features,
|
||||||
|
'style' => ['color' => $this->layerColor ?: '#3b82f6'] // Podrías guardar el color en la tabla layers
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $layer->id,
|
||||||
|
'geojson' => $geojson,
|
||||||
|
'color' => $geojson['style']['color'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->dispatch('initialLayersData', [
|
||||||
|
'layers' => $layersData,
|
||||||
|
'visibleLayers' => $this->visibleLayers,
|
||||||
|
'selectedLayerId' => $this->selectedLayer?->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleLayerVisibility($layerId)
|
||||||
|
{
|
||||||
|
if ($this->selectedLayer && $this->selectedLayer->id == $layerId) {
|
||||||
|
session()->flash('info', 'No puedes ocultar la capa que estás editando.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (in_array($layerId, $this->visibleLayers)) {
|
||||||
|
$this->visibleLayers = array_diff($this->visibleLayers, [$layerId]);
|
||||||
|
} else {
|
||||||
|
$this->visibleLayers[] = $layerId;
|
||||||
|
}
|
||||||
|
$this->dispatch('visibilityChanged', $this->visibleLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectLayer($layerId)
|
||||||
|
{
|
||||||
|
$this->selectedLayer = Layer::with('features')->find($layerId);
|
||||||
|
if (!$this->selectedLayer) return;
|
||||||
|
|
||||||
|
if (!in_array($layerId, $this->visibleLayers)) {
|
||||||
|
$this->visibleLayers[] = $layerId;
|
||||||
|
$this->dispatch('visibilityChanged', $this->visibleLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construir el GeoJSON desde los features de la capa seleccionada
|
||||||
|
$features = $this->selectedLayer->features->map(function($feature) {
|
||||||
|
return [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'id' => $feature->id,
|
||||||
|
'geometry' => $feature->geometry,
|
||||||
|
'properties' => [
|
||||||
|
'name' => $feature->name,
|
||||||
|
'progress' => $feature->progress,
|
||||||
|
'responsible' => $feature->responsible,
|
||||||
|
'template_id' => $feature->template_id,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
})->values()->toArray();
|
||||||
|
|
||||||
|
$geojson = [
|
||||||
|
'type' => 'FeatureCollection',
|
||||||
|
'features' => $features,
|
||||||
|
'style' => ['color' => $this->layerColor ?: '#3b82f6']
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dispatch('layerSelectedForEdit', [
|
||||||
|
'layerId' => $layerId,
|
||||||
|
'geojson' => $geojson,
|
||||||
|
'color' => $geojson['style']['color'],
|
||||||
|
]);
|
||||||
|
session()->flash('info', 'Editando capa: ' . $this->selectedLayer->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function importFile()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user->can('upload layers') && !$user->hasRole('Admin')) {
|
||||||
|
session()->flash('error', 'Sin permisos.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validar campos obligatorios y tamaño máximo
|
||||||
|
$this->validate([
|
||||||
|
'uploadFile' => 'required|file|max:51200',
|
||||||
|
'layerName' => 'required|string|max:255',
|
||||||
|
'layerColor' => 'nullable|string|size:7',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$extension = strtolower($this->uploadFile->getClientOriginalExtension());
|
||||||
|
$mime = $this->uploadFile->getMimeType();
|
||||||
|
|
||||||
|
$allowedExtensions = ['geojson', 'kmz', 'kml', 'shp', 'dwg', 'zip'];
|
||||||
|
$allowedMimes = [
|
||||||
|
'application/vnd.google-earth.kml+xml',
|
||||||
|
'application/vnd.google-earth.kmz',
|
||||||
|
'application/zip',
|
||||||
|
'application/x-zip-compressed',
|
||||||
|
'application/x-shapefile',
|
||||||
|
'image/vnd.dwg',
|
||||||
|
'application/acad',
|
||||||
|
'application/geo+json',
|
||||||
|
'text/xml', // ✅ Aceptar KML con text/xml
|
||||||
|
'application/xml', // ✅ Alternativa
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!in_array($extension, $allowedExtensions) && !in_array($mime, $allowedMimes)) {
|
||||||
|
session()->flash('error', 'Tipo de archivo no permitido. Extensiones válidas: ' . implode(', ', $allowedExtensions));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectDir = "uploads/projects/{$this->project->id}/layers";
|
||||||
|
$originalPath = $this->uploadFile->store($projectDir, 'public');
|
||||||
|
$geojson = SpatialFileConverter::convertToGeoJson($this->uploadFile);
|
||||||
|
|
||||||
|
if (!$geojson) {
|
||||||
|
session()->flash('error', 'Conversión fallida. Asegúrate de que el archivo sea válido (KML, GeoJSON, etc.).');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$geojson['style'] = ['color' => $this->layerColor ?: '#3b82f6'];
|
||||||
|
|
||||||
|
$layer = Layer::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'phase_id' => $this->phase->id,
|
||||||
|
'name' => $this->layerName,
|
||||||
|
//'geojson_data' => $geojson,
|
||||||
|
'original_file' => $originalPath,
|
||||||
|
'uploaded_by' => $user->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Crear features a partir del GeoJSON
|
||||||
|
if (isset($geojson['features'])) {
|
||||||
|
foreach ($geojson['features'] as $featureData) {
|
||||||
|
Feature::create([
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'name' => $featureData['properties']['name'] ?? null,
|
||||||
|
'geometry' => $featureData['geometry'],
|
||||||
|
'properties' => $featureData['properties'] ?? [],
|
||||||
|
'template_id' => $featureData['properties']['template_id'] ?? null,
|
||||||
|
'progress' => $featureData['properties']['progress'] ?? 0,
|
||||||
|
'responsible' => $featureData['properties']['responsible'] ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadLayers();
|
||||||
|
$this->visibleLayers[] = $layer->id;
|
||||||
|
$this->reset(['uploadFile', 'layerName']);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa importada correctamente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createEmptyLayer()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
$layer = Layer::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'phase_id' => $this->phase->id,
|
||||||
|
'name' => $this->layerName ?: 'Nueva capa',
|
||||||
|
'original_file' => null,
|
||||||
|
'uploaded_by' => $user->id,
|
||||||
|
// Opcional: guarda el color en una columna 'color' de la tabla layers
|
||||||
|
]);
|
||||||
|
$this->loadLayers();
|
||||||
|
$this->visibleLayers[] = $layer->id;
|
||||||
|
$this->selectLayer($layer->id);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa vacía creada. Usa el editor para añadir elementos.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveManualGeojson($geojsonString)
|
||||||
|
{
|
||||||
|
if (!$this->selectedLayer) {
|
||||||
|
session()->flash('error', 'No hay capa seleccionada.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$geojson = json_decode($geojsonString, true);
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE || !isset($geojson['features'])) {
|
||||||
|
session()->flash('error', 'GeoJSON inválido.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eliminar todos los features existentes de esta capa
|
||||||
|
$this->selectedLayer->features()->delete();
|
||||||
|
|
||||||
|
// Crear nuevos features a partir del GeoJSON
|
||||||
|
foreach ($geojson['features'] as $featureData) {
|
||||||
|
Feature::create([
|
||||||
|
'layer_id' => $this->selectedLayer->id,
|
||||||
|
'name' => $featureData['properties']['name'] ?? null,
|
||||||
|
'geometry' => $featureData['geometry'],
|
||||||
|
'properties' => $featureData['properties'] ?? [],
|
||||||
|
'template_id' => $featureData['properties']['template_id'] ?? null,
|
||||||
|
'progress' => $featureData['properties']['progress'] ?? 0,
|
||||||
|
'responsible' => $featureData['properties']['responsible'] ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadLayers();
|
||||||
|
$this->selectLayer($this->selectedLayer->id);
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa guardada con ' . count($geojson['features']) . ' elementos.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteLayer($layerId)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user->can('delete layers') && !$user->hasRole('Admin')) abort(403);
|
||||||
|
$layer = Layer::find($layerId);
|
||||||
|
if (!$layer) return;
|
||||||
|
if ($layer->original_file) Storage::disk('public')->delete($layer->original_file);
|
||||||
|
$layer->features()->delete(); // opcional, si no usas cascade
|
||||||
|
$layer->delete();
|
||||||
|
$this->loadLayers();
|
||||||
|
if ($this->selectedLayer && $this->selectedLayer->id == $layerId) {
|
||||||
|
$this->selectedLayer = null;
|
||||||
|
}
|
||||||
|
$this->emitInitialLayersData();
|
||||||
|
session()->flash('message', 'Capa eliminada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelEditing()
|
||||||
|
{
|
||||||
|
$this->selectedLayer = null;
|
||||||
|
$this->dispatch('layerSelectedForEdit', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.layers.layer-manager');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class LayerUpload extends Component
|
||||||
|
{
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.layer-upload');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
|
||||||
|
class PhaseList extends Component
|
||||||
|
{
|
||||||
|
public Project $project;
|
||||||
|
public $phases;
|
||||||
|
|
||||||
|
public function mount(Project $project)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->phases = $project->phases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPhase()
|
||||||
|
{
|
||||||
|
$this->project->phases()->create([
|
||||||
|
'name' => 'Nueva fase',
|
||||||
|
'order' => $this->phases->count() + 1,
|
||||||
|
'color' => '#'.substr(md5(rand()), 0, 6)
|
||||||
|
]);
|
||||||
|
$this->phases = $this->project->phases()->get();
|
||||||
|
session()->flash('message', 'Fase agregada');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deletePhase($phaseId)
|
||||||
|
{
|
||||||
|
Phase::find($phaseId)->delete();
|
||||||
|
$this->phases = $this->project->phases()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.phase-list');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\Phase;
|
||||||
|
|
||||||
|
class PhaseProgress extends Component
|
||||||
|
{
|
||||||
|
public Phase $phase;
|
||||||
|
public $progress;
|
||||||
|
public $comment = '';
|
||||||
|
|
||||||
|
public function mount(Phase $phase)
|
||||||
|
{
|
||||||
|
$this->phase = $phase;
|
||||||
|
$this->progress = $phase->progress_percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateProgressManual()
|
||||||
|
{
|
||||||
|
$this->validate(['progress' => 'required|integer|min:0|max:100']);
|
||||||
|
$this->phase->progress_percent = $this->progress;
|
||||||
|
$this->phase->save();
|
||||||
|
|
||||||
|
$this->phase->progressUpdates()->create([
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'progress_percent' => $this->progress,
|
||||||
|
'comment' => $this->comment,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('progressUpdated', $this->phase->id, $this->progress);
|
||||||
|
session()->flash('message', 'Progreso actualizado');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.phase-progress');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class ProjectForm extends Component
|
||||||
|
{
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.projects.project-form');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithPagination;
|
||||||
|
use App\Models\Project;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ProjectList extends Component
|
||||||
|
{
|
||||||
|
use WithPagination;
|
||||||
|
|
||||||
|
public $search = '';
|
||||||
|
public $statusFilter = '';
|
||||||
|
|
||||||
|
public function deleteProject($id)
|
||||||
|
{
|
||||||
|
$project = Project::findOrFail($id);
|
||||||
|
if (Auth::user()->can('delete projects')) {
|
||||||
|
$project->delete();
|
||||||
|
session()->flash('message', 'Proyecto eliminado');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$query = Project::accessibleBy(Auth::user());
|
||||||
|
if ($this->search) {
|
||||||
|
$query->where('name', 'like', '%' . $this->search . '%');
|
||||||
|
}
|
||||||
|
if ($this->statusFilter) {
|
||||||
|
$query->where('status', $this->statusFilter);
|
||||||
|
}
|
||||||
|
$projects = $query->latest()->paginate(10);
|
||||||
|
return view('livewire.projects.project-list', ['projects' => $projects]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use App\Models\Inspection;
|
||||||
|
use App\Models\InspectionTemplate;
|
||||||
|
use App\Models\Feature;
|
||||||
|
|
||||||
|
class ProjectMap extends Component
|
||||||
|
{
|
||||||
|
public Project $project;
|
||||||
|
public $phases;
|
||||||
|
public $activeLayers = []; // Array of phase IDs to show
|
||||||
|
|
||||||
|
// Editor properties
|
||||||
|
public $selectedFeature = null;
|
||||||
|
public $selectedPhaseId = null;
|
||||||
|
public $editProgress = 0;
|
||||||
|
public $editComment = '';
|
||||||
|
public $editResponsible = '';
|
||||||
|
public $editPhotos = [];
|
||||||
|
public $formFullscreen = false;
|
||||||
|
|
||||||
|
// Propiedades para templates e inspecciones
|
||||||
|
public $templates = [];
|
||||||
|
public $selectedTemplateId = null;
|
||||||
|
public $inspectionFormData = [];
|
||||||
|
public $inspectionHistory = [];
|
||||||
|
public $showInspectionForm = true;
|
||||||
|
|
||||||
|
public function mount(Project $project)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->phases = $project->phases()->with('currentLayer')->get();
|
||||||
|
$this->activeLayers = $this->phases->pluck('id')->toArray();
|
||||||
|
|
||||||
|
$this->loadTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleLayer($phaseId)
|
||||||
|
{
|
||||||
|
if (in_array($phaseId, $this->activeLayers)) {
|
||||||
|
$this->activeLayers = array_diff($this->activeLayers, [$phaseId]);
|
||||||
|
} else {
|
||||||
|
$this->activeLayers[] = $phaseId;
|
||||||
|
}
|
||||||
|
$this->dispatch('layersUpdated', $this->activeLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateProgress($featureId, $newProgress, $comment = null)
|
||||||
|
{
|
||||||
|
$feature = Feature::findOrFail($featureId);
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (!$user->can('update progress') && !$user->hasRole('Admin')) {
|
||||||
|
$this->dispatch('notify', 'Sin permisos');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$feature->progress = min(100, max(0, $newProgress));
|
||||||
|
$feature->save();
|
||||||
|
|
||||||
|
// Actualizar progreso de la fase (sumar promedio)
|
||||||
|
$phase = Phase::find($feature->layer->phase_id);
|
||||||
|
$phase->progress_percent = $phase->features()->avg('progress');
|
||||||
|
$phase->save();
|
||||||
|
|
||||||
|
$phase->progressUpdates()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'progress_percent' => $phase->progress_percent,
|
||||||
|
'comment' => $comment,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('progressUpdated', $featureId, $feature->progress);
|
||||||
|
$this->dispatch('notify', 'Progreso actualizado');
|
||||||
|
$this->editProgress = $feature->progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadTemplates()
|
||||||
|
{
|
||||||
|
$this->templates = InspectionTemplate::where('project_id', $this->project->id)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectFeature($featureId, $featureProps)
|
||||||
|
{
|
||||||
|
$feature = Feature::with('template')->find($featureId);
|
||||||
|
if (!$feature) return;
|
||||||
|
|
||||||
|
$this->selectedFeature = $feature;
|
||||||
|
$this->selectedPhaseId = $feature->layer->phase_id;
|
||||||
|
$this->editProgress = $feature->progress;
|
||||||
|
$this->editResponsible = $feature->responsible;
|
||||||
|
$this->selectedTemplateId = $feature->template_id;
|
||||||
|
|
||||||
|
$this->loadInspectionHistory();
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
|
||||||
|
$this->dispatch('featureSelected', $featureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveFeatureProgress()
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature || !$this->selectedPhaseId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->updateProgress($this->selectedPhaseId, $this->editProgress, $this->editComment);
|
||||||
|
$this->editComment = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetInspectionForm()
|
||||||
|
{
|
||||||
|
$this->inspectionFormData = [];
|
||||||
|
if ($this->selectedTemplateId) {
|
||||||
|
$template = InspectionTemplate::find($this->selectedTemplateId);
|
||||||
|
if ($template) {
|
||||||
|
foreach ($template->fields as $field) {
|
||||||
|
$this->inspectionFormData[$field['name']] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadInspectionHistory()
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature || !$this->selectedPhaseId) {
|
||||||
|
$this->inspectionHistory = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$layer = Phase::find($this->selectedPhaseId)->currentLayer;
|
||||||
|
if ($layer) {
|
||||||
|
$this->inspectionHistory = Inspection::where('layer_id', $layer->id)
|
||||||
|
->where('feature_id', $this->selectedFeature['id'])
|
||||||
|
->with('user', 'template')
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveInspection()
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature || !$this->selectedPhaseId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->validate([
|
||||||
|
'selectedTemplateId' => 'required|exists:inspection_templates,id',
|
||||||
|
]);
|
||||||
|
$layer = Phase::find($this->selectedPhaseId)->currentLayer;
|
||||||
|
if (!$layer) return;
|
||||||
|
|
||||||
|
$inspection = Inspection::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'layer_id' => $this->selectedFeature->layer_id,
|
||||||
|
'feature_id' => $this->selectedFeature->id,
|
||||||
|
'template_id' => $this->selectedTemplateId,
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'data' => $this->inspectionFormData,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Opcional: actualizar el progreso del elemento en el GeoJSON
|
||||||
|
if (isset($this->inspectionFormData['progress'])) {
|
||||||
|
$this->updateProgress($this->selectedPhaseId, $this->inspectionFormData['progress'], 'Inspección registrada');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadInspectionHistory();
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
$this->dispatch('notify', 'Inspección guardada');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateFeatureTemplate($templateId)
|
||||||
|
{
|
||||||
|
// Actualizar el template asociado al elemento (podrías guardarlo en la capa GeoJSON)
|
||||||
|
if ($this->selectedFeature && $this->selectedPhaseId) {
|
||||||
|
$layer = Phase::find($this->selectedPhaseId)->currentLayer;
|
||||||
|
if ($layer) {
|
||||||
|
$geojson = $layer->geojson_data;
|
||||||
|
foreach ($geojson['features'] as &$feature) {
|
||||||
|
if ($feature['properties']['id'] == $this->selectedFeature['id']) {
|
||||||
|
$feature['properties']['template_id'] = $templateId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$layer->geojson_data = $geojson;
|
||||||
|
$layer->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->selectedTemplateId = $templateId;
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleFullscreen()
|
||||||
|
{
|
||||||
|
$this->formFullscreen = !$this->formFullscreen;
|
||||||
|
if (!$this->formFullscreen) {
|
||||||
|
$this->dispatch('mapResize');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añadir al final de la clase ProjectMap
|
||||||
|
public function refreshTemplates()
|
||||||
|
{
|
||||||
|
$this->templates = InspectionTemplate::where('project_id', $this->project->id)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asignar template ahora actualiza el campo template_id
|
||||||
|
public function assignTemplateToFeature($templateId)
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature) return;
|
||||||
|
$this->selectedFeature->template_id = $templateId;
|
||||||
|
$this->selectedFeature->save();
|
||||||
|
$this->selectedTemplateId = $templateId;
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
$this->dispatch('notify', 'Template asignado');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.projects.project-map', [
|
||||||
|
'project' => $this->project,
|
||||||
|
'phases' => $this->phases,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use App\Models\Layer;
|
||||||
|
use App\Models\Feature;
|
||||||
|
use App\Models\Inspection;
|
||||||
|
use App\Models\InspectionTemplate;
|
||||||
|
|
||||||
|
class ProjectMap extends Component
|
||||||
|
{
|
||||||
|
public Project $project;
|
||||||
|
public $phases;
|
||||||
|
public $activeLayers = [];
|
||||||
|
|
||||||
|
// Editor properties
|
||||||
|
public $selectedFeature = null; // será instancia de Feature
|
||||||
|
public $selectedPhaseId = null;
|
||||||
|
public $editProgress = 0;
|
||||||
|
public $editComment = '';
|
||||||
|
public $editResponsible = '';
|
||||||
|
public $editPhotos = [];
|
||||||
|
public $formFullscreen = false;
|
||||||
|
|
||||||
|
// Templates e inspecciones
|
||||||
|
public $templates = [];
|
||||||
|
public $selectedTemplateId = null;
|
||||||
|
public $inspectionFormData = [];
|
||||||
|
public $inspectionHistory = [];
|
||||||
|
|
||||||
|
public function mount(Project $project)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
// Cargar fases con sus capas y los features de esas capas (para mostrarlos en el mapa)
|
||||||
|
$this->phases = $project->phases()->with(['layers.features'])->get();
|
||||||
|
// Por defecto mostrar todas las capas activas (todas las fases que tengan alguna capa con features)
|
||||||
|
$this->activeLayers = $this->phases->pluck('id')->toArray();
|
||||||
|
$this->loadTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadTemplates()
|
||||||
|
{
|
||||||
|
$this->templates = InspectionTemplate::where('project_id', $this->project->id)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleLayer($phaseId)
|
||||||
|
{
|
||||||
|
if (in_array($phaseId, $this->activeLayers)) {
|
||||||
|
$this->activeLayers = array_diff($this->activeLayers, [$phaseId]);
|
||||||
|
} else {
|
||||||
|
$this->activeLayers[] = $phaseId;
|
||||||
|
}
|
||||||
|
$this->dispatch('layersUpdated', $this->activeLayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actualizar el progreso de un Feature y recalcular el progreso de la fase.
|
||||||
|
*/
|
||||||
|
public function updateProgress($featureId, $newProgress, $comment = null)
|
||||||
|
{
|
||||||
|
$feature = Feature::findOrFail($featureId);
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (!$user->can('update progress') && !$user->hasRole('Admin')) {
|
||||||
|
$this->dispatch('notify', 'Sin permisos');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oldProgress = $feature->progress;
|
||||||
|
$feature->progress = min(100, max(0, $newProgress));
|
||||||
|
$feature->save();
|
||||||
|
|
||||||
|
// Recalcular el progreso de la fase (promedio de todos sus features)
|
||||||
|
$phase = Phase::find($feature->layer->phase_id);
|
||||||
|
$phase->progress_percent = $phase->features()->avg('progress') ?: 0;
|
||||||
|
$phase->save();
|
||||||
|
|
||||||
|
// Registrar la actualización en progress_updates
|
||||||
|
$phase->progressUpdates()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'progress_percent' => $phase->progress_percent,
|
||||||
|
'comment' => $comment,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('progressUpdated', $featureId, $feature->progress);
|
||||||
|
$this->dispatch('notify', 'Progreso actualizado');
|
||||||
|
|
||||||
|
// Si el feature seleccionado es el mismo, actualizar la propiedad local
|
||||||
|
if ($this->selectedFeature && $this->selectedFeature->id == $featureId) {
|
||||||
|
$this->selectedFeature->progress = $feature->progress;
|
||||||
|
$this->editProgress = $feature->progress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seleccionar un Feature al hacer clic en el mapa.
|
||||||
|
*/
|
||||||
|
public function selectFeature($featureId)
|
||||||
|
{
|
||||||
|
$feature = Feature::with('template')->find($featureId);
|
||||||
|
if (!$feature) return;
|
||||||
|
|
||||||
|
$this->selectedFeature = $feature;
|
||||||
|
$this->selectedPhaseId = $feature->layer->phase_id;
|
||||||
|
$this->editProgress = $feature->progress;
|
||||||
|
$this->editResponsible = $feature->responsible ?? '';
|
||||||
|
$this->editPhotos = $feature->properties['photos'] ?? [];
|
||||||
|
$this->selectedTemplateId = $feature->template_id;
|
||||||
|
|
||||||
|
$this->loadInspectionHistory();
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
|
||||||
|
$this->dispatch('featureSelected', $featureId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cargar el historial de inspecciones del feature seleccionado.
|
||||||
|
*/
|
||||||
|
public function loadInspectionHistory()
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature) {
|
||||||
|
$this->inspectionHistory = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->inspectionHistory = Inspection::where('feature_id', $this->selectedFeature->id)
|
||||||
|
->with('user', 'template')
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reiniciar el formulario de inspección según el template seleccionado.
|
||||||
|
*/
|
||||||
|
public function resetInspectionForm()
|
||||||
|
{
|
||||||
|
$this->inspectionFormData = [];
|
||||||
|
if ($this->selectedTemplateId) {
|
||||||
|
$template = InspectionTemplate::find($this->selectedTemplateId);
|
||||||
|
if ($template) {
|
||||||
|
foreach ($template->fields as $field) {
|
||||||
|
$this->inspectionFormData[$field['name']] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guardar una nueva inspección.
|
||||||
|
*/
|
||||||
|
public function saveInspection()
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature || !$this->selectedTemplateId) {
|
||||||
|
$this->dispatch('notify', 'Selecciona un elemento y un template.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validate([
|
||||||
|
'selectedTemplateId' => 'required|exists:inspection_templates,id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$template = InspectionTemplate::find($this->selectedTemplateId);
|
||||||
|
foreach ($template->fields as $field) {
|
||||||
|
if (($field['required'] ?? false) && empty($this->inspectionFormData[$field['name']])) {
|
||||||
|
$this->dispatch('notify', "El campo {$field['label']} es obligatorio.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$inspection = Inspection::create([
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'layer_id' => $this->selectedFeature->layer_id,
|
||||||
|
'feature_id' => $this->selectedFeature->id,
|
||||||
|
'template_id' => $this->selectedTemplateId,
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'data' => $this->inspectionFormData,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Si el template tiene un campo llamado 'progress', actualizar el progreso del feature
|
||||||
|
if (isset($this->inspectionFormData['progress'])) {
|
||||||
|
$this->updateProgress($this->selectedFeature->id, (int)$this->inspectionFormData['progress'], 'Inspección registrada');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadInspectionHistory();
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
$this->dispatch('notify', 'Inspección guardada correctamente');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asignar un template al feature seleccionado.
|
||||||
|
*/
|
||||||
|
public function assignTemplateToFeature($templateId)
|
||||||
|
{
|
||||||
|
if (!$this->selectedFeature) return;
|
||||||
|
|
||||||
|
$this->selectedFeature->template_id = $templateId;
|
||||||
|
$this->selectedFeature->save();
|
||||||
|
|
||||||
|
$this->selectedTemplateId = $templateId;
|
||||||
|
$this->resetInspectionForm();
|
||||||
|
$this->dispatch('notify', 'Template asignado al elemento');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toggleFullscreen()
|
||||||
|
{
|
||||||
|
$this->formFullscreen = !$this->formFullscreen;
|
||||||
|
if (!$this->formFullscreen) {
|
||||||
|
$this->dispatch('mapResize');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.projects.project-map', [
|
||||||
|
'project' => $this->project,
|
||||||
|
'phases' => $this->phases,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use App\Models\InspectionTemplate;
|
||||||
|
use App\Models\Project;
|
||||||
|
|
||||||
|
class TemplateManager extends Component
|
||||||
|
{
|
||||||
|
public $project;
|
||||||
|
public $templates;
|
||||||
|
public $editingTemplate = null;
|
||||||
|
public $showForm = false; // Controla si mostrar el formulario
|
||||||
|
public $form = [
|
||||||
|
'name' => '',
|
||||||
|
'description' => '',
|
||||||
|
'fields' => [],
|
||||||
|
];
|
||||||
|
public $fieldTypes = [
|
||||||
|
'text' => 'Texto corto',
|
||||||
|
'textarea' => 'Texto largo',
|
||||||
|
'integer' => 'Número entero',
|
||||||
|
'decimal' => 'Número decimal',
|
||||||
|
'percentage' => 'Porcentaje (0-100)',
|
||||||
|
'boolean' => 'Sí/No (checkbox)',
|
||||||
|
'date' => 'Fecha',
|
||||||
|
'select' => 'Lista desplegable',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function mount(Project $project)
|
||||||
|
{
|
||||||
|
$this->project = $project;
|
||||||
|
$this->loadTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadTemplates()
|
||||||
|
{
|
||||||
|
$this->templates = InspectionTemplate::where('project_id', $this->project->id)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newTemplate()
|
||||||
|
{
|
||||||
|
$this->resetForm();
|
||||||
|
$this->editingTemplate = null;
|
||||||
|
$this->showForm = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editTemplate($id)
|
||||||
|
{
|
||||||
|
$template = InspectionTemplate::find($id);
|
||||||
|
$this->form = $template->only(['name', 'description', 'fields']);
|
||||||
|
$this->editingTemplate = $id;
|
||||||
|
$this->showForm = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelForm()
|
||||||
|
{
|
||||||
|
$this->showForm = false;
|
||||||
|
$this->resetForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetForm()
|
||||||
|
{
|
||||||
|
$this->form = [
|
||||||
|
'name' => '',
|
||||||
|
'description' => '',
|
||||||
|
'fields' => [],
|
||||||
|
];
|
||||||
|
$this->editingTemplate = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addField()
|
||||||
|
{
|
||||||
|
$this->form['fields'][] = [
|
||||||
|
'name' => '',
|
||||||
|
'label' => '',
|
||||||
|
'type' => 'text',
|
||||||
|
'options' => [],
|
||||||
|
'required' => false,
|
||||||
|
'min' => null,
|
||||||
|
'max' => null,
|
||||||
|
'step' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeField($index)
|
||||||
|
{
|
||||||
|
unset($this->form['fields'][$index]);
|
||||||
|
$this->form['fields'] = array_values($this->form['fields']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveTemplate()
|
||||||
|
{
|
||||||
|
$this->validate([
|
||||||
|
'form.name' => 'required|string|max:255',
|
||||||
|
'form.fields' => 'array',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($this->editingTemplate) {
|
||||||
|
$template = InspectionTemplate::find($this->editingTemplate);
|
||||||
|
$template->update($this->form);
|
||||||
|
session()->flash('message', 'Template actualizado');
|
||||||
|
} else {
|
||||||
|
InspectionTemplate::create([
|
||||||
|
'name' => $this->form['name'],
|
||||||
|
'description' => $this->form['description'],
|
||||||
|
'project_id' => $this->project->id,
|
||||||
|
'fields' => $this->form['fields'],
|
||||||
|
]);
|
||||||
|
session()->flash('message', 'Template creado');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->cancelForm();
|
||||||
|
$this->loadTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteTemplate($id)
|
||||||
|
{
|
||||||
|
InspectionTemplate::find($id)->delete();
|
||||||
|
$this->loadTemplates();
|
||||||
|
session()->flash('message', 'Template eliminado');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.template-manager');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Feature extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'layer_id', 'name', 'geometry', 'properties', 'template_id', 'progress', 'responsible'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'geometry' => 'array',
|
||||||
|
'properties' => 'array',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function layer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Layer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function template()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(InspectionTemplate::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function inspections()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Inspection::class, 'feature_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Inspection extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['project_id', 'layer_id', 'feature_id', 'template_id', 'user_id', 'data'];
|
||||||
|
|
||||||
|
protected $casts = ['data' => 'array'];
|
||||||
|
|
||||||
|
public function project()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Project::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function layer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Layer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function template()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(InspectionTemplate::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class InspectionTemplate extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['name', 'description', 'project_id', 'fields'];
|
||||||
|
|
||||||
|
protected $casts = ['fields' => 'array'];
|
||||||
|
|
||||||
|
public function project()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Project::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function inspections()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Inspection::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
|
||||||
|
class Layer extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'project_id', 'phase_id', 'name', 'geojson_data', 'original_file', 'uploaded_by'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'geojson_data' => 'array',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function project()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Project::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function phase()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Phase::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploader()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'uploaded_by');
|
||||||
|
}
|
||||||
|
public function features()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Feature::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PendingSync extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['user_id', 'action', 'payload', 'synced_at'];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'payload' => 'array',
|
||||||
|
'synced_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Phase extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'project_id', 'name', 'description', 'order', 'color', 'progress_percent'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function project()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Project::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function layers()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Layer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function progressUpdates()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProgressUpdate::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get latest active layer (most recent upload)
|
||||||
|
public function currentLayer()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Layer::class)->latestOfMany();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ProgressUpdate extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'phase_id', 'user_id', 'progress_percent', 'comment', 'location'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'location' => 'array', // Store as [lat, lng]
|
||||||
|
];
|
||||||
|
|
||||||
|
public function phase()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Phase::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Project extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'address', 'lat', 'lng', 'start_date', 'end_date_estimated', 'status', 'created_by'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'start_date' => 'date',
|
||||||
|
'end_date_estimated' => 'date',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Relationships
|
||||||
|
public function phases()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Phase::class)->orderBy('order');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function layers()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Layer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function users()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(User::class)->withPivot('role_in_project');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function creator()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'created_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scope to filter accessible projects for non-admin users
|
||||||
|
public function scopeAccessibleBy($query, User $user)
|
||||||
|
{
|
||||||
|
if ($user->hasRole('Admin')) {
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
return $query->whereHas('users', function ($q) use ($user) {
|
||||||
|
$q->where('user_id', $user->id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Database\Factories\UserFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
/** @use HasFactory<UserFactory> */
|
||||||
|
use HasFactory, Notifiable, HasRoles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
'password' => 'hashed',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// Many-to-many with projects
|
||||||
|
public function projects()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Project::class)->withPivot('role_in_project')->withTimestamps();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Progress updates made
|
||||||
|
public function progressUpdates()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProgressUpdate::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Livewire\Volt\Volt;
|
||||||
|
|
||||||
|
class VoltServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
Volt::mount([
|
||||||
|
config('livewire.view_path', resource_path('views/livewire')),
|
||||||
|
resource_path('views/pages'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,336 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Shapefile\ShapefileReader;
|
||||||
|
|
||||||
|
class SpatialFileConverter
|
||||||
|
{
|
||||||
|
public static function convertToGeoJson(UploadedFile $file): ?array
|
||||||
|
{
|
||||||
|
$ext = strtolower($file->getClientOriginalExtension());
|
||||||
|
$path = $file->getPathname();
|
||||||
|
|
||||||
|
$geojson = match ($ext) {
|
||||||
|
'geojson' => self::parseGeoJson($path),
|
||||||
|
'kml' => self::kmlToGeoJson($path),
|
||||||
|
'shp' => self::shapefileToGeoJson($path),
|
||||||
|
'zip' => self::handleZip($path),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!$geojson) return null;
|
||||||
|
|
||||||
|
return self::postProcess($geojson);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
POST PROCESADO PRO
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function postProcess(array $geojson): array
|
||||||
|
{
|
||||||
|
$features = [];
|
||||||
|
|
||||||
|
foreach ($geojson['features'] ?? [] as $feature) {
|
||||||
|
|
||||||
|
if (!isset($feature['geometry'])) continue;
|
||||||
|
|
||||||
|
$geometry = self::cleanGeometry($feature['geometry']);
|
||||||
|
if (!$geometry) continue;
|
||||||
|
|
||||||
|
$features[] = [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'geometry' => $geometry,
|
||||||
|
'properties' => self::normalizeProperties($feature['properties'] ?? [])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => 'FeatureCollection',
|
||||||
|
'features' => $features,
|
||||||
|
'bbox' => self::calculateBBox($features),
|
||||||
|
'centroid' => self::calculateCentroid($features)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
NORMALIZACIÓN
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function normalizeProperties(array $props): array
|
||||||
|
{
|
||||||
|
return array_merge([
|
||||||
|
'name' => '',
|
||||||
|
'description' => '',
|
||||||
|
], $props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
GEOMETRY CLEAN
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function cleanGeometry(array $geom): ?array
|
||||||
|
{
|
||||||
|
if (!isset($geom['type'], $geom['coordinates'])) return null;
|
||||||
|
|
||||||
|
if ($geom['type'] === 'Polygon') {
|
||||||
|
$geom['coordinates'] = array_map(function ($ring) {
|
||||||
|
if ($ring[0] !== end($ring)) {
|
||||||
|
$ring[] = $ring[0];
|
||||||
|
}
|
||||||
|
return $ring;
|
||||||
|
}, $geom['coordinates']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $geom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
BBOX
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function calculateBBox(array $features): ?array
|
||||||
|
{
|
||||||
|
$coords = [];
|
||||||
|
|
||||||
|
foreach ($features as $f) {
|
||||||
|
$coords = array_merge($coords, self::flattenCoords($f['geometry']['coordinates']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($coords)) return null;
|
||||||
|
|
||||||
|
$lons = array_column($coords, 0);
|
||||||
|
$lats = array_column($coords, 1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
min($lons),
|
||||||
|
min($lats),
|
||||||
|
max($lons),
|
||||||
|
max($lats)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
CENTROIDE SIMPLE
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function calculateCentroid(array $features): ?array
|
||||||
|
{
|
||||||
|
$coords = [];
|
||||||
|
|
||||||
|
foreach ($features as $f) {
|
||||||
|
$coords = array_merge($coords, self::flattenCoords($f['geometry']['coordinates']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($coords)) return null;
|
||||||
|
|
||||||
|
$x = array_sum(array_column($coords, 0)) / count($coords);
|
||||||
|
$y = array_sum(array_column($coords, 1)) / count($coords);
|
||||||
|
|
||||||
|
return [$x, $y];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function flattenCoords($coords): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
$iterator = function ($c) use (&$result, &$iterator) {
|
||||||
|
if (!is_array($c)) return;
|
||||||
|
|
||||||
|
if (isset($c[0]) && isset($c[1]) && is_numeric($c[0])) {
|
||||||
|
$result[] = [$c[0], $c[1]];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($c as $item) {
|
||||||
|
$iterator($item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$iterator($coords);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
GEOJSON
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function parseGeoJson($path): ?array
|
||||||
|
{
|
||||||
|
$data = json_decode(file_get_contents($path), true);
|
||||||
|
return json_last_error() === JSON_ERROR_NONE ? $data : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
KML (MEJORADO)
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function kmlToGeoJson($path): ?array
|
||||||
|
{
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
$xml = simplexml_load_file($path);
|
||||||
|
|
||||||
|
if (!$xml) return null;
|
||||||
|
|
||||||
|
$xml->registerXPathNamespace('kml', 'http://www.opengis.net/kml/2.2');
|
||||||
|
|
||||||
|
$placemarks = $xml->xpath('//kml:Placemark');
|
||||||
|
|
||||||
|
$features = [];
|
||||||
|
|
||||||
|
foreach ($placemarks as $pm) {
|
||||||
|
$geom = self::parseKmlGeometry($pm);
|
||||||
|
if (!$geom) continue;
|
||||||
|
|
||||||
|
$features[] = [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'geometry' => $geom,
|
||||||
|
'properties' => [
|
||||||
|
'name' => (string)$pm->name,
|
||||||
|
'description' => (string)$pm->description
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'FeatureCollection', 'features' => $features];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function parseKmlGeometry($pm): ?array
|
||||||
|
{
|
||||||
|
if (isset($pm->MultiGeometry)) {
|
||||||
|
$geoms = [];
|
||||||
|
|
||||||
|
foreach ($pm->MultiGeometry->children() as $g) {
|
||||||
|
$parsed = self::parseKmlGeometry($g);
|
||||||
|
if ($parsed) $geoms[] = $parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => 'GeometryCollection',
|
||||||
|
'geometries' => $geoms
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($pm->Point)) {
|
||||||
|
return [
|
||||||
|
'type' => 'Point',
|
||||||
|
'coordinates' => self::parseKmlCoords((string)$pm->Point->coordinates)[0]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($pm->LineString)) {
|
||||||
|
return [
|
||||||
|
'type' => 'LineString',
|
||||||
|
'coordinates' => self::parseKmlCoords((string)$pm->LineString->coordinates)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($pm->Polygon)) {
|
||||||
|
return [
|
||||||
|
'type' => 'Polygon',
|
||||||
|
'coordinates' => [
|
||||||
|
self::parseKmlCoords(
|
||||||
|
(string)$pm->Polygon->outerBoundaryIs->LinearRing->coordinates
|
||||||
|
)
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function parseKmlCoords(string $text): array
|
||||||
|
{
|
||||||
|
$coords = [];
|
||||||
|
foreach (preg_split('/\s+/', trim($text)) as $pair) {
|
||||||
|
$p = explode(',', $pair);
|
||||||
|
if (count($p) >= 2) {
|
||||||
|
$coords[] = [(float)$p[0], (float)$p[1]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
SHP REAL
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function shapefileToGeoJson($path): ?array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$reader = new ShapefileReader($path);
|
||||||
|
|
||||||
|
$features = [];
|
||||||
|
|
||||||
|
while ($record = $reader->fetchRecord()) {
|
||||||
|
if ($record->isDeleted()) continue;
|
||||||
|
|
||||||
|
$geom = json_decode($record->getGeometry()->toGeoJSON(), true);
|
||||||
|
|
||||||
|
if (!$geom) continue;
|
||||||
|
|
||||||
|
$features[] = [
|
||||||
|
'type' => 'Feature',
|
||||||
|
'geometry' => $geom,
|
||||||
|
'properties' => $record->getDataArray()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['type' => 'FeatureCollection', 'features' => $features];
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =======================
|
||||||
|
ZIP LIMPIO
|
||||||
|
======================= */
|
||||||
|
|
||||||
|
private static function handleZip($zipPath): ?array
|
||||||
|
{
|
||||||
|
$zip = new \ZipArchive();
|
||||||
|
|
||||||
|
if ($zip->open($zipPath) !== true) return null;
|
||||||
|
|
||||||
|
$dir = sys_get_temp_dir() . '/geo_' . uniqid();
|
||||||
|
mkdir($dir);
|
||||||
|
|
||||||
|
$zip->extractTo($dir);
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
$result = null;
|
||||||
|
|
||||||
|
foreach (scandir($dir) as $file) {
|
||||||
|
$full = $dir . '/' . $file;
|
||||||
|
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
if ($ext === 'shp') {
|
||||||
|
$result = self::shapefileToGeoJson($full);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ext === 'kml') {
|
||||||
|
$result = self::kmlToGeoJson($full);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::deleteDir($dir);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function deleteDir($dir)
|
||||||
|
{
|
||||||
|
foreach (glob("$dir/*") as $file) {
|
||||||
|
is_dir($file) ? self::deleteDir($file) : unlink($file);
|
||||||
|
}
|
||||||
|
rmdir($dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?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): void {
|
||||||
|
//
|
||||||
|
})
|
||||||
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
|
//
|
||||||
|
})->create();
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\VoltServiceProvider::class,
|
||||||
|
];
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"$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",
|
||||||
|
"blade-ui-kit/blade-heroicons": "^2.7",
|
||||||
|
"gasparesganga/php-shapefile": "^3.4",
|
||||||
|
"laravel/framework": "^12.0",
|
||||||
|
"laravel/tinker": "^2.10.1",
|
||||||
|
"league/geotools": "^1.3",
|
||||||
|
"livewire/livewire": "^3.6.4",
|
||||||
|
"livewire/volt": "^1.7.0",
|
||||||
|
"mansoor/blade-lets-icons": "^1.0",
|
||||||
|
"phayes/geophp": "^1.2",
|
||||||
|
"spatie/laravel-permission": "^6.25"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/breeze": "^2.4",
|
||||||
|
"laravel/pail": "^1.2.2",
|
||||||
|
"laravel/pint": "^1.24",
|
||||||
|
"laravel/sail": "^1.41",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"nunomaduro/collision": "^8.6",
|
||||||
|
"phpunit/phpunit": "^11.5.50"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"setup": [
|
||||||
|
"composer install",
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||||
|
"@php artisan key:generate",
|
||||||
|
"@php artisan migrate --force",
|
||||||
|
"npm install",
|
||||||
|
"npm run build"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||||
|
],
|
||||||
|
"test": [
|
||||||
|
"@php artisan config:clear --ansi",
|
||||||
|
"@php artisan test"
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
],
|
||||||
|
"pre-package-uninstall": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"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
|
||||||
|
}
|
||||||
Generated
+9768
File diff suppressed because it is too large
Load Diff
+126
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the name of your application, which will be used when the
|
||||||
|
| framework needs to place the application's name in a notification or
|
||||||
|
| other UI elements where an application name needs to be displayed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the "environment" your application is currently
|
||||||
|
| running in. This may determine how you prefer to configure various
|
||||||
|
| services the application utilizes. Set this in your ".env" file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Debug Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When your application is in debug mode, detailed error messages with
|
||||||
|
| stack traces will be shown on every error that occurs within your
|
||||||
|
| application. If disabled, a simple generic error page is shown.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application URL
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This URL is used by the console to properly generate URLs when using
|
||||||
|
| the Artisan command line tool. You should set this to the root of
|
||||||
|
| the application so that it's available within Artisan commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default timezone for your application, which
|
||||||
|
| will be used by the PHP date and date-time functions. The timezone
|
||||||
|
| is set to "UTC" by default as it is suitable for most use cases.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The application locale determines the default locale that will be used
|
||||||
|
| by Laravel's translation / localization methods. This option can be
|
||||||
|
| set to any locale for which you plan to have translation strings.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => env('APP_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This key is utilized by Laravel's encryption services and should be set
|
||||||
|
| to a random, 32 character string to ensure that all encrypted values
|
||||||
|
| are secure. You should do this prior to deploying the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'previous_keys' => [
|
||||||
|
...array_filter(
|
||||||
|
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maintenance Mode Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options determine the driver used to determine and
|
||||||
|
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||||
|
| allow maintenance mode to be controlled across multiple machines.
|
||||||
|
|
|
||||||
|
| Supported drivers: "file", "cache"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'maintenance' => [
|
||||||
|
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||||
|
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
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', 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),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<?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",
|
||||||
|
| "failover", "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',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'driver' => 'failover',
|
||||||
|
'stores' => [
|
||||||
|
'database',
|
||||||
|
'array',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Pdo\Mysql;
|
||||||
|
|
||||||
|
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,
|
||||||
|
'transaction_mode' => 'DEFERRED',
|
||||||
|
],
|
||||||
|
|
||||||
|
'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([
|
||||||
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : 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([
|
||||||
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : 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' => env('DB_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((string) 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'),
|
||||||
|
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||||
|
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||||
|
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||||
|
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||||
|
],
|
||||||
|
|
||||||
|
'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'),
|
||||||
|
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||||
|
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||||
|
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||||
|
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -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' => rtrim(env('APP_URL', 'http://localhost'), '/').'/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'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -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(',', (string) 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', env('APP_NAME', 'Laravel')),
|
||||||
|
'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
@@ -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((string) 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', env('APP_NAME', 'Laravel')),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\Permission\DefaultTeamResolver;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
|
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' => 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' => 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' => 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',
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?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",
|
||||||
|
| "deferred", "background", "failover", "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,
|
||||||
|
],
|
||||||
|
|
||||||
|
'deferred' => [
|
||||||
|
'driver' => 'deferred',
|
||||||
|
],
|
||||||
|
|
||||||
|
'background' => [
|
||||||
|
'driver' => 'background',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'driver' => 'failover',
|
||||||
|
'connections' => [
|
||||||
|
'database',
|
||||||
|
'deferred',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -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' => [
|
||||||
|
'key' => env('POSTMARK_API_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'key' => env('RESEND_API_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'notifications' => [
|
||||||
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -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((string) 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 without 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),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*.sqlite*
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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')->index();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('cache_locks', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->string('owner');
|
||||||
|
$table->integer('expiration')->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cache');
|
||||||
|
Schema::dropIfExists('cache_locks');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('projects', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('address');
|
||||||
|
$table->decimal('lat', 10, 8);
|
||||||
|
$table->decimal('lng', 11, 8);
|
||||||
|
$table->date('start_date');
|
||||||
|
$table->date('end_date_estimated')->nullable();
|
||||||
|
$table->enum('status', ['planning', 'in_progress', 'paused', 'completed'])->default('planning');
|
||||||
|
$table->foreignId('created_by')->constrained('users');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('projects');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('phases', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('project_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->integer('order')->default(0);
|
||||||
|
$table->string('color', 7)->default('#3b82f6'); // hex color
|
||||||
|
$table->integer('progress_percent')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('phases');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('layers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('project_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('phase_id')->nullable()->constrained()->onDelete('set null');
|
||||||
|
$table->string('name');
|
||||||
|
$table->json('geojson_data'); // GeoJSON geometry collection
|
||||||
|
$table->string('original_file')->nullable(); // path to original uploaded file
|
||||||
|
$table->foreignId('uploaded_by')->constrained('users');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('layers');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('progress_updates', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('phase_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('user_id')->constrained();
|
||||||
|
$table->integer('progress_percent');
|
||||||
|
$table->text('comment')->nullable();
|
||||||
|
$table->json('location')->nullable(); // GPS point from mobile
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('progress_updates');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('pending_syncs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained();
|
||||||
|
$table->string('action'); // 'progress_update', 'task_complete'
|
||||||
|
$table->json('payload');
|
||||||
|
$table->timestamp('synced_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('pending_syncs');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('project_user', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('project_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('role_in_project'); // supervisor, consultant, client
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('project_user');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$teams = config('permission.teams');
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
$columnNames = config('permission.column_names');
|
||||||
|
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||||
|
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
throw_if($teams && empty($columnNames['team_foreign_key'] ?? null), Exception::class, 'Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||||
|
|
||||||
|
Schema::create($tableNames['permissions'], static function (Blueprint $table) {
|
||||||
|
// $table->engine('InnoDB');
|
||||||
|
$table->bigIncrements('id'); // permission id
|
||||||
|
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||||
|
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) {
|
||||||
|
// $table->engine('InnoDB');
|
||||||
|
$table->bigIncrements('id'); // role id
|
||||||
|
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||||
|
}
|
||||||
|
$table->string('name'); // For MyISAM use string('name', 225); // (or 166 for InnoDB with Redundant/Compact row format)
|
||||||
|
$table->string('guard_name'); // For MyISAM use string('guard_name', 25);
|
||||||
|
$table->timestamps();
|
||||||
|
if ($teams || config('permission.testing')) {
|
||||||
|
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||||
|
} else {
|
||||||
|
$table->unique(['name', 'guard_name']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->onDelete('cascade');
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_permissions_permission_model_type_primary');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->string('model_type');
|
||||||
|
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||||
|
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->onDelete('cascade');
|
||||||
|
if ($teams) {
|
||||||
|
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||||
|
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||||
|
|
||||||
|
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
} else {
|
||||||
|
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||||
|
'model_has_roles_role_model_type_primary');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||||
|
$table->unsignedBigInteger($pivotPermission);
|
||||||
|
$table->unsignedBigInteger($pivotRole);
|
||||||
|
|
||||||
|
$table->foreign($pivotPermission)
|
||||||
|
->references('id') // permission id
|
||||||
|
->on($tableNames['permissions'])
|
||||||
|
->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->foreign($pivotRole)
|
||||||
|
->references('id') // role id
|
||||||
|
->on($tableNames['roles'])
|
||||||
|
->onDelete('cascade');
|
||||||
|
|
||||||
|
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||||
|
});
|
||||||
|
|
||||||
|
app('cache')
|
||||||
|
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||||
|
->forget(config('permission.cache.key'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$tableNames = config('permission.table_names');
|
||||||
|
|
||||||
|
throw_if(empty($tableNames), Exception::class, 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||||
|
|
||||||
|
Schema::drop($tableNames['role_has_permissions']);
|
||||||
|
Schema::drop($tableNames['model_has_roles']);
|
||||||
|
Schema::drop($tableNames['model_has_permissions']);
|
||||||
|
Schema::drop($tableNames['roles']);
|
||||||
|
Schema::drop($tableNames['permissions']);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?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('inspection_templates', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->foreignId('project_id')->nullable()->constrained()->onDelete('cascade');
|
||||||
|
$table->json('fields'); // [{name, label, type, options, required}]
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('inspection_templates');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('inspections', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('project_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->foreignId('layer_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('feature_id'); // ID del elemento GeoJSON
|
||||||
|
$table->foreignId('template_id')->nullable()->constrained('inspection_templates')->onDelete('set null');
|
||||||
|
$table->foreignId('user_id')->constrained();
|
||||||
|
$table->json('data'); // Valores de los campos del template
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('inspections');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('features', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('layer_id')->constrained()->onDelete('cascade');
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->json('geometry'); // GeoJSON geometry object (Point, LineString, Polygon)
|
||||||
|
$table->json('properties')->nullable(); // propiedades extra (progreso, responsable, etc.)
|
||||||
|
$table->foreignId('template_id')->nullable()->constrained('inspection_templates');
|
||||||
|
$table->integer('progress')->default(0);
|
||||||
|
$table->string('responsible')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('features');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
// Primero eliminar la columna antigua (si existe) y crear la nueva
|
||||||
|
Schema::table('inspections', function (Blueprint $table) {
|
||||||
|
// Si ya existe como string, la eliminamos
|
||||||
|
if (Schema::hasColumn('inspections', 'feature_id')) {
|
||||||
|
$table->dropColumn('feature_id');
|
||||||
|
}
|
||||||
|
$table->foreignId('feature_id')->constrained('features')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('inspections', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['feature_id']);
|
||||||
|
$table->dropColumn('feature_id');
|
||||||
|
$table->string('feature_id')->nullable(); // rollback opcional
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('layers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('geojson_data');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('layers', function (Blueprint $table) {
|
||||||
|
$table->json('geojson_data'); // GeoJSON geometry collection
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('layers', function (Blueprint $table) {
|
||||||
|
$table->string('color', 7)->default('#3b82f6')->after('name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('layers', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('color');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
use WithoutModelEvents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seed the application's database.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// User::factory(10)->create();
|
||||||
|
|
||||||
|
/*User::factory()->create([
|
||||||
|
'name' => 'Test User',
|
||||||
|
'email' => 'test@example.com',
|
||||||
|
]);*/
|
||||||
|
|
||||||
|
|
||||||
|
$this->call([
|
||||||
|
RolesAndPermissionsSeeder::class,
|
||||||
|
ProjectExampleSeeder::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Phase;
|
||||||
|
use App\Models\Layer;
|
||||||
|
use App\Models\Feature;
|
||||||
|
use App\Models\InspectionTemplate;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class ProjectExampleSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
// Obtener usuario admin
|
||||||
|
$admin = User::where('email', 'admin@email.com')->first();
|
||||||
|
if (!$admin) {
|
||||||
|
$admin = User::first();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crear proyecto
|
||||||
|
$project = Project::create([
|
||||||
|
'name' => 'Edificio Central',
|
||||||
|
'address' => 'Av. Principal 123, Ciudad',
|
||||||
|
'lat' => 40.416775,
|
||||||
|
'lng' => -3.703790,
|
||||||
|
'start_date' => now(),
|
||||||
|
'end_date_estimated' => now()->addMonths(12),
|
||||||
|
'status' => 'in_progress',
|
||||||
|
'created_by' => $admin->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$project->users()->attach($admin->id, ['role_in_project' => 'supervisor']);
|
||||||
|
|
||||||
|
// Crear fases
|
||||||
|
$phases = [
|
||||||
|
['name' => 'Cimientos', 'order' => 1, 'color' => '#ef4444'],
|
||||||
|
['name' => 'Estructura', 'order' => 2, 'color' => '#3b82f6'],
|
||||||
|
['name' => 'Instalaciones', 'order' => 3, 'color' => '#10b981'],
|
||||||
|
['name' => 'Acabados', 'order' => 4, 'color' => '#f59e0b'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($phases as $phaseData) {
|
||||||
|
Phase::create(array_merge($phaseData, ['project_id' => $project->id, 'progress_percent' => 0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$phaseCimientos = Phase::where('project_id', $project->id)->where('name', 'Cimientos')->first();
|
||||||
|
|
||||||
|
// Crear templates de inspección
|
||||||
|
$templateHormigon = InspectionTemplate::create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'name' => 'Control de hormigón',
|
||||||
|
'fields' => [
|
||||||
|
['name' => 'progress', 'label' => 'Progreso de vertido', 'type' => 'percentage', 'required' => true],
|
||||||
|
['name' => 'calidad', 'label' => 'Calidad del hormigón', 'type' => 'select', 'options' => 'Excelente,Bueno,Regular,Deficiente', 'required' => true],
|
||||||
|
['name' => 'observaciones', 'label' => 'Observaciones', 'type' => 'textarea', 'required' => false],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$templateAcero = InspectionTemplate::create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'name' => 'Control de acero',
|
||||||
|
'fields' => [
|
||||||
|
['name' => 'progress', 'label' => '% de acero colocado', 'type' => 'percentage', 'required' => true],
|
||||||
|
['name' => 'diametros', 'label' => 'Diámetros verificados', 'type' => 'text', 'required' => false],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Crear capa (sin geojson_data)
|
||||||
|
$layer = Layer::create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'phase_id' => $phaseCimientos->id,
|
||||||
|
'name' => 'Plano de cimientos',
|
||||||
|
'original_file' => null,
|
||||||
|
'uploaded_by' => $admin->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Crear features (elementos geográficos)
|
||||||
|
$feature1 = Feature::create([
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'name' => 'Zapata A1',
|
||||||
|
'geometry' => [
|
||||||
|
'type' => 'Polygon',
|
||||||
|
'coordinates' => [[
|
||||||
|
[-3.705, 40.415],
|
||||||
|
[-3.702, 40.415],
|
||||||
|
[-3.702, 40.418],
|
||||||
|
[-3.705, 40.418],
|
||||||
|
[-3.705, 40.415]
|
||||||
|
]]
|
||||||
|
],
|
||||||
|
'properties' => ['description' => 'Zapata esquina noroeste'],
|
||||||
|
'template_id' => $templateHormigon->id,
|
||||||
|
'progress' => 45,
|
||||||
|
'responsible' => 'Ing. Gómez',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$feature2 = Feature::create([
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'name' => 'Zapata B1',
|
||||||
|
'geometry' => [
|
||||||
|
'type' => 'Polygon',
|
||||||
|
'coordinates' => [[
|
||||||
|
[-3.700, 40.415],
|
||||||
|
[-3.697, 40.415],
|
||||||
|
[-3.697, 40.418],
|
||||||
|
[-3.700, 40.418],
|
||||||
|
[-3.700, 40.415]
|
||||||
|
]]
|
||||||
|
],
|
||||||
|
'properties' => ['description' => 'Zapata lado este'],
|
||||||
|
'template_id' => $templateAcero->id,
|
||||||
|
'progress' => 80,
|
||||||
|
'responsible' => 'Arq. Martínez',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Feature::create([
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'name' => 'Punto de control topográfico',
|
||||||
|
'geometry' => [
|
||||||
|
'type' => 'Point',
|
||||||
|
'coordinates' => [-3.703, 40.4165]
|
||||||
|
],
|
||||||
|
'properties' => ['tipo' => 'estación total'],
|
||||||
|
'template_id' => null,
|
||||||
|
'progress' => 100,
|
||||||
|
'responsible' => 'Topógrafo Pérez',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// (Opcional) Crear una inspección de ejemplo
|
||||||
|
\App\Models\Inspection::create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'layer_id' => $layer->id,
|
||||||
|
'feature_id' => $feature1->id,
|
||||||
|
'template_id' => $templateHormigon->id,
|
||||||
|
'user_id' => $admin->id,
|
||||||
|
'data' => [
|
||||||
|
'progress' => 45,
|
||||||
|
'calidad' => 'Bueno',
|
||||||
|
'observaciones' => 'Vertido completado en un 45%, sin fisuras aparentes.'
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class RolesAndPermissionsSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
// Reset cached roles and permissions
|
||||||
|
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
|
// Create permissions
|
||||||
|
$permissions = [
|
||||||
|
'view projects', 'create projects', 'edit projects', 'delete projects',
|
||||||
|
'assign users', 'upload layers', 'update progress', 'view reports', 'manage all'
|
||||||
|
];
|
||||||
|
foreach ($permissions as $perm) {
|
||||||
|
Permission::firstOrCreate(['name' => $perm]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create roles and assign permissions
|
||||||
|
$admin = Role::firstOrCreate(['name' => 'Admin']);
|
||||||
|
$admin->givePermissionTo(Permission::all());
|
||||||
|
|
||||||
|
$supervisor = Role::firstOrCreate(['name' => 'Supervisor']);
|
||||||
|
$supervisor->givePermissionTo(['view projects', 'upload layers', 'update progress']);
|
||||||
|
|
||||||
|
$consultor = Role::firstOrCreate(['name' => 'Consultor']);
|
||||||
|
$consultor->givePermissionTo(['view projects', 'view reports']);
|
||||||
|
|
||||||
|
$cliente = Role::firstOrCreate(['name' => 'Cliente']);
|
||||||
|
$cliente->givePermissionTo(['view projects']);
|
||||||
|
|
||||||
|
// Create default admin user
|
||||||
|
$user = User::factory()->create([
|
||||||
|
'name' => 'Admin User',
|
||||||
|
'email' => 'admin@email.com',
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
]);
|
||||||
|
$user->assignRole('Admin');
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+3544
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://www.schemastore.org/package.json",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build",
|
||||||
|
"dev": "vite"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/forms": "^0.5.2",
|
||||||
|
"@tailwindcss/vite": "^4.0.0",
|
||||||
|
"autoprefixer": "^10.5.0",
|
||||||
|
"axios": "^1.11.0",
|
||||||
|
"concurrently": "^9.0.1",
|
||||||
|
"daisyui": "^5.5.19",
|
||||||
|
"laravel-vite-plugin": "^2.0.0",
|
||||||
|
"postcss": "^8.5.12",
|
||||||
|
"tailwindcss": "^3.4.19",
|
||||||
|
"vite": "^7.0.7"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@tailwindcss/typography": "^0.5.19",
|
||||||
|
"apexcharts": "^5.10.6",
|
||||||
|
"chart.js": "^4.5.1",
|
||||||
|
"localforage": "^1.10.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Unit">
|
||||||
|
<directory>tests/Unit</directory>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="Feature">
|
||||||
|
<directory>tests/Feature</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>app</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
<php>
|
||||||
|
<env name="APP_ENV" value="testing"/>
|
||||||
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
|
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||||
|
<env name="BROADCAST_CONNECTION" value="null"/>
|
||||||
|
<env name="CACHE_STORE" value="array"/>
|
||||||
|
<env name="DB_CONNECTION" value="sqlite"/>
|
||||||
|
<env name="DB_DATABASE" value=":memory:"/>
|
||||||
|
<env name="DB_URL" value=""/>
|
||||||
|
<env name="MAIL_MAILER" value="array"/>
|
||||||
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
<env name="SESSION_DRIVER" value="array"/>
|
||||||
|
<env name="PULSE_ENABLED" value="false"/>
|
||||||
|
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||||
|
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||||
|
</php>
|
||||||
|
</phpunit>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews -Indexes
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Handle Authorization Header
|
||||||
|
RewriteCond %{HTTP:Authorization} .
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
|
||||||
|
# Handle X-XSRF-Token Header
|
||||||
|
RewriteCond %{HTTP:x-xsrf-token} .
|
||||||
|
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||||
|
|
||||||
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_URI} (.+)/$
|
||||||
|
RewriteRule ^ %1 [L,R=301]
|
||||||
|
|
||||||
|
# Send Requests To Front Controller...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
</IfModule>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
// Determine if the application is in maintenance mode...
|
||||||
|
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
|
||||||
|
require $maintenance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the Composer autoloader...
|
||||||
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
// Bootstrap Laravel and handle the request...
|
||||||
|
/** @var Application $app */
|
||||||
|
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||||
|
|
||||||
|
$app->handleRequest(Request::capture());
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow:
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import './bootstrap';
|
||||||
|
|
||||||
|
import localforage from 'localforage';
|
||||||
|
|
||||||
|
// Sync pending actions when online
|
||||||
|
window.addEventListener('online', () => {
|
||||||
|
fetch('/offline/sync', { method: 'POST', headers: { 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content } })
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => console.log('Synced:', data));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function to store offline progress update
|
||||||
|
window.offlineProgressUpdate = function(phaseId, progress, comment, location) {
|
||||||
|
const payload = { phase_id: phaseId, progress, comment, location };
|
||||||
|
if (navigator.onLine) {
|
||||||
|
fetch('/offline/pending', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content },
|
||||||
|
body: JSON.stringify({ action: 'progress_update', payload })
|
||||||
|
}).then(() => alert('Actualizado online'));
|
||||||
|
} else {
|
||||||
|
localforage.getItem('pendingOffline').then(pending => {
|
||||||
|
const list = pending || [];
|
||||||
|
list.push(payload);
|
||||||
|
localforage.setItem('pendingOffline', list);
|
||||||
|
alert('Guardado localmente, se sincronizará al recuperar internet');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
window.axios = axios;
|
||||||
|
|
||||||
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@props(['on'])
|
||||||
|
|
||||||
|
<div x-data="{ shown: false, timeout: null }"
|
||||||
|
x-init="@this.on('{{ $on }}', () => { clearTimeout(timeout); shown = true; timeout = setTimeout(() => { shown = false }, 2000); })"
|
||||||
|
x-show.transition.out.opacity.duration.1500ms="shown"
|
||||||
|
x-transition:leave.opacity.duration.1500ms
|
||||||
|
style="display: none;"
|
||||||
|
{{ $attributes->merge(['class' => 'text-sm text-gray-600']) }}>
|
||||||
|
{{ $slot->isEmpty() ? __('Saved.') : $slot }}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg viewBox="0 0 316 316" xmlns="http://www.w3.org/2000/svg" {{ $attributes }}>
|
||||||
|
<path d="M305.8 81.125C305.77 80.995 305.69 80.885 305.65 80.755C305.56 80.525 305.49 80.285 305.37 80.075C305.29 79.935 305.17 79.815 305.07 79.685C304.94 79.515 304.83 79.325 304.68 79.175C304.55 79.045 304.39 78.955 304.25 78.845C304.09 78.715 303.95 78.575 303.77 78.475L251.32 48.275C249.97 47.495 248.31 47.495 246.96 48.275L194.51 78.475C194.33 78.575 194.19 78.725 194.03 78.845C193.89 78.955 193.73 79.045 193.6 79.175C193.45 79.325 193.34 79.515 193.21 79.685C193.11 79.815 192.99 79.935 192.91 80.075C192.79 80.285 192.71 80.525 192.63 80.755C192.58 80.875 192.51 80.995 192.48 81.125C192.38 81.495 192.33 81.875 192.33 82.265V139.625L148.62 164.795V52.575C148.62 52.185 148.57 51.805 148.47 51.435C148.44 51.305 148.36 51.195 148.32 51.065C148.23 50.835 148.16 50.595 148.04 50.385C147.96 50.245 147.84 50.125 147.74 49.995C147.61 49.825 147.5 49.635 147.35 49.485C147.22 49.355 147.06 49.265 146.92 49.155C146.76 49.025 146.62 48.885 146.44 48.785L93.99 18.585C92.64 17.805 90.98 17.805 89.63 18.585L37.18 48.785C37 48.885 36.86 49.035 36.7 49.155C36.56 49.265 36.4 49.355 36.27 49.485C36.12 49.635 36.01 49.825 35.88 49.995C35.78 50.125 35.66 50.245 35.58 50.385C35.46 50.595 35.38 50.835 35.3 51.065C35.25 51.185 35.18 51.305 35.15 51.435C35.05 51.805 35 52.185 35 52.575V232.235C35 233.795 35.84 235.245 37.19 236.025L142.1 296.425C142.33 296.555 142.58 296.635 142.82 296.725C142.93 296.765 143.04 296.835 143.16 296.865C143.53 296.965 143.9 297.015 144.28 297.015C144.66 297.015 145.03 296.965 145.4 296.865C145.5 296.835 145.59 296.775 145.69 296.745C145.95 296.655 146.21 296.565 146.45 296.435L251.36 236.035C252.72 235.255 253.55 233.815 253.55 232.245V174.885L303.81 145.945C305.17 145.165 306 143.725 306 142.155V82.265C305.95 81.875 305.89 81.495 305.8 81.125ZM144.2 227.205L100.57 202.515L146.39 176.135L196.66 147.195L240.33 172.335L208.29 190.625L144.2 227.205ZM244.75 114.995V164.795L226.39 154.225L201.03 139.625V89.825L219.39 100.395L244.75 114.995ZM249.12 57.105L292.81 82.265L249.12 107.425L205.43 82.265L249.12 57.105ZM114.49 184.425L96.13 194.995V85.305L121.49 70.705L139.85 60.135V169.815L114.49 184.425ZM91.76 27.425L135.45 52.585L91.76 77.745L48.07 52.585L91.76 27.425ZM43.67 60.135L62.03 70.705L87.39 85.305V202.545V202.555V202.565C87.39 202.735 87.44 202.895 87.46 203.055C87.49 203.265 87.49 203.485 87.55 203.695V203.705C87.6 203.875 87.69 204.035 87.76 204.195C87.84 204.375 87.89 204.575 87.99 204.745C87.99 204.745 87.99 204.755 88 204.755C88.09 204.905 88.22 205.035 88.33 205.175C88.45 205.335 88.55 205.495 88.69 205.635L88.7 205.645C88.82 205.765 88.98 205.855 89.12 205.965C89.28 206.085 89.42 206.225 89.59 206.325C89.6 206.325 89.6 206.325 89.61 206.335C89.62 206.335 89.62 206.345 89.63 206.345L139.87 234.775V285.065L43.67 229.705V60.135ZM244.75 229.705L148.58 285.075V234.775L219.8 194.115L244.75 179.875V229.705ZM297.2 139.625L253.49 164.795V114.995L278.85 100.395L297.21 89.825V139.625H297.2Z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
@props(['status'])
|
||||||
|
|
||||||
|
@if ($status)
|
||||||
|
<div {{ $attributes->merge(['class' => 'font-medium text-sm text-green-600']) }}>
|
||||||
|
{{ $status }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<button {{ $attributes->merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-red-500 active:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition ease-in-out duration-150']) }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</button>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<a {{ $attributes->merge(['class' => 'block w-full px-4 py-2 text-start text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out']) }}>{{ $slot }}</a>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
@props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white'])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$alignmentClasses = match ($align) {
|
||||||
|
'left' => 'ltr:origin-top-left rtl:origin-top-right start-0',
|
||||||
|
'top' => 'origin-top',
|
||||||
|
default => 'ltr:origin-top-right rtl:origin-top-left end-0',
|
||||||
|
};
|
||||||
|
|
||||||
|
$width = match ($width) {
|
||||||
|
'48' => 'w-48',
|
||||||
|
default => $width,
|
||||||
|
};
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="relative" x-data="{ open: false }" @click.outside="open = false" @close.stop="open = false">
|
||||||
|
<div @click="open = ! open">
|
||||||
|
{{ $trigger }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div x-show="open"
|
||||||
|
x-transition:enter="transition ease-out duration-200"
|
||||||
|
x-transition:enter-start="opacity-0 scale-95"
|
||||||
|
x-transition:enter-end="opacity-100 scale-100"
|
||||||
|
x-transition:leave="transition ease-in duration-75"
|
||||||
|
x-transition:leave-start="opacity-100 scale-100"
|
||||||
|
x-transition:leave-end="opacity-0 scale-95"
|
||||||
|
class="absolute z-50 mt-2 {{ $width }} rounded-md shadow-lg {{ $alignmentClasses }}"
|
||||||
|
style="display: none;"
|
||||||
|
@click="open = false">
|
||||||
|
<div class="rounded-md ring-1 ring-black ring-opacity-5 {{ $contentClasses }}">
|
||||||
|
{{ $content }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@props(['messages'])
|
||||||
|
|
||||||
|
@if ($messages)
|
||||||
|
<ul {{ $attributes->merge(['class' => 'text-sm text-red-600 space-y-1']) }}>
|
||||||
|
@foreach ((array) $messages as $message)
|
||||||
|
<li>{{ $message }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@props(['value'])
|
||||||
|
|
||||||
|
<label {{ $attributes->merge(['class' => 'block font-medium text-sm text-gray-700']) }}>
|
||||||
|
{{ $value ?? $slot }}
|
||||||
|
</label>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
@props([
|
||||||
|
'name',
|
||||||
|
'show' => false,
|
||||||
|
'maxWidth' => '2xl'
|
||||||
|
])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$maxWidth = [
|
||||||
|
'sm' => 'sm:max-w-sm',
|
||||||
|
'md' => 'sm:max-w-md',
|
||||||
|
'lg' => 'sm:max-w-lg',
|
||||||
|
'xl' => 'sm:max-w-xl',
|
||||||
|
'2xl' => 'sm:max-w-2xl',
|
||||||
|
][$maxWidth];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div
|
||||||
|
x-data="{
|
||||||
|
show: @js($show),
|
||||||
|
focusables() {
|
||||||
|
// All focusable element types...
|
||||||
|
let selector = 'a, button, input:not([type=\'hidden\']), textarea, select, details, [tabindex]:not([tabindex=\'-1\'])'
|
||||||
|
return [...$el.querySelectorAll(selector)]
|
||||||
|
// All non-disabled elements...
|
||||||
|
.filter(el => ! el.hasAttribute('disabled'))
|
||||||
|
},
|
||||||
|
firstFocusable() { return this.focusables()[0] },
|
||||||
|
lastFocusable() { return this.focusables().slice(-1)[0] },
|
||||||
|
nextFocusable() { return this.focusables()[this.nextFocusableIndex()] || this.firstFocusable() },
|
||||||
|
prevFocusable() { return this.focusables()[this.prevFocusableIndex()] || this.lastFocusable() },
|
||||||
|
nextFocusableIndex() { return (this.focusables().indexOf(document.activeElement) + 1) % (this.focusables().length + 1) },
|
||||||
|
prevFocusableIndex() { return Math.max(0, this.focusables().indexOf(document.activeElement)) -1 },
|
||||||
|
}"
|
||||||
|
x-init="$watch('show', value => {
|
||||||
|
if (value) {
|
||||||
|
document.body.classList.add('overflow-y-hidden');
|
||||||
|
{{ $attributes->has('focusable') ? 'setTimeout(() => firstFocusable().focus(), 100)' : '' }}
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove('overflow-y-hidden');
|
||||||
|
}
|
||||||
|
})"
|
||||||
|
x-on:open-modal.window="$event.detail == '{{ $name }}' ? show = true : null"
|
||||||
|
x-on:close-modal.window="$event.detail == '{{ $name }}' ? show = false : null"
|
||||||
|
x-on:close.stop="show = false"
|
||||||
|
x-on:keydown.escape.window="show = false"
|
||||||
|
x-on:keydown.tab.prevent="$event.shiftKey || nextFocusable().focus()"
|
||||||
|
x-on:keydown.shift.tab.prevent="prevFocusable().focus()"
|
||||||
|
x-show="show"
|
||||||
|
class="fixed inset-0 overflow-y-auto px-4 py-6 sm:px-0 z-50"
|
||||||
|
style="display: {{ $show ? 'block' : 'none' }};"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
x-show="show"
|
||||||
|
class="fixed inset-0 transform transition-all"
|
||||||
|
x-on:click="show = false"
|
||||||
|
x-transition:enter="ease-out duration-300"
|
||||||
|
x-transition:enter-start="opacity-0"
|
||||||
|
x-transition:enter-end="opacity-100"
|
||||||
|
x-transition:leave="ease-in duration-200"
|
||||||
|
x-transition:leave-start="opacity-100"
|
||||||
|
x-transition:leave-end="opacity-0"
|
||||||
|
>
|
||||||
|
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
x-show="show"
|
||||||
|
class="mb-6 bg-white rounded-lg overflow-hidden shadow-xl transform transition-all sm:w-full {{ $maxWidth }} sm:mx-auto"
|
||||||
|
x-transition:enter="ease-out duration-300"
|
||||||
|
x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
x-transition:leave="ease-in duration-200"
|
||||||
|
x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
>
|
||||||
|
{{ $slot }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@props(['active'])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$classes = ($active ?? false)
|
||||||
|
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out'
|
||||||
|
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out';
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<a {{ $attributes->merge(['class' => $classes]) }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</a>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<button {{ $attributes->merge(['type' => 'submit', 'class' => 'inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 focus:bg-gray-700 active:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition ease-in-out duration-150']) }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</button>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@props(['active'])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$classes = ($active ?? false)
|
||||||
|
? 'block w-full ps-3 pe-4 py-2 border-l-4 border-indigo-400 text-start text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition duration-150 ease-in-out'
|
||||||
|
: 'block w-full ps-3 pe-4 py-2 border-l-4 border-transparent text-start text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition duration-150 ease-in-out';
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<a {{ $attributes->merge(['class' => $classes]) }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</a>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<button {{ $attributes->merge(['type' => 'button', 'class' => 'inline-flex items-center px-4 py-2 bg-white border border-gray-300 rounded-md font-semibold text-xs text-gray-700 uppercase tracking-widest shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:opacity-25 transition ease-in-out duration-150']) }}>
|
||||||
|
{{ $slot }}
|
||||||
|
</button>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user