From c9a514b0fa011700812433c7b034cf9a3587aaa5 Mon Sep 17 00:00:00 2001 From: amikhaylov Date: Mon, 18 May 2026 23:43:26 +0300 Subject: [PATCH] Added Breeze --- app/Http/Controllers/MapController.php | 12 +-- app/Http/Controllers/PlacesController.php | 52 ++++++++++++ app/Models/Loaders/GigsLoader.php | 14 ++-- app/Models/Loaders/UsersLoader.php | 20 +++-- app/Models/ORM/ContactRole.php | 14 ++++ app/Models/ORM/Place.php | 8 +- app/Models/Objects/Contact.php | 13 +-- app/Providers/AppServiceProvider.php | 3 +- composer.json | 3 +- .../0001_01_01_000000_create_users_table.php | 18 ++++- database/seeders/DatabaseSeeder.php | 12 ++- package.json | 6 +- resources/css/app.css | 14 +--- resources/js/app.js | 6 ++ resources/views/places/index.blade.php | 81 +++++++++++++++++++ routes/web.php | 25 ++++++ vite.config.js | 7 -- 17 files changed, 249 insertions(+), 59 deletions(-) create mode 100644 app/Http/Controllers/PlacesController.php create mode 100644 app/Models/ORM/ContactRole.php create mode 100644 resources/views/places/index.blade.php diff --git a/app/Http/Controllers/MapController.php b/app/Http/Controllers/MapController.php index 6c7b125..9a6f1b6 100644 --- a/app/Http/Controllers/MapController.php +++ b/app/Http/Controllers/MapController.php @@ -14,13 +14,12 @@ class MapController extends Controller private array $apiParams; - public function index(int $id) { - $this->apiParams = array( + $this->apiParams = [ "apikey" => $this->yandex_key, "lang" =>"ru_RU", - ); + ]; $apiCall = $this->createApiCall(); @@ -32,10 +31,13 @@ class MapController extends Controller public function getPlace(int $id) { $place = Place::find($id); - [ $x, $y ] = explode("|",$place->Gps); + [ $x, $y ] = explode("|", $place->gps); return response()->json([ - 'x' => $x, 'y' => $y + 'x' => $x, + 'y' => $y, + 'id' => $id, + 'name' => $place->Name, ]); } diff --git a/app/Http/Controllers/PlacesController.php b/app/Http/Controllers/PlacesController.php new file mode 100644 index 0000000..a450d3d --- /dev/null +++ b/app/Http/Controllers/PlacesController.php @@ -0,0 +1,52 @@ +validate([ + 'name' => 'required|string|max:255', + 'lat' => 'required|numeric', + 'lng' => 'required|numeric', + ]); + + Place::create($data); + + return redirect() + ->route('places.index') + ->with('status', 'Локация создана!'); + } + + public function edit(Place $place) { + return view('places.edit', compact('place')); + } + + public function update(Request $request, Place $place) { + $data = $request->validate([ + 'name' => 'required|string|max:255', + 'lat' => 'required|numeric', + 'lng' => 'required|numeric', + ]); + $place->update($data); + return redirect() + ->route('places.index') + ->with('status', 'Обновлено!'); + } + + public function destroy(Place $place) { + $place->delete(); + return redirect() + ->route('places.index') + ->with('status', 'Удалено!'); + } +} diff --git a/app/Models/Loaders/GigsLoader.php b/app/Models/Loaders/GigsLoader.php index 41a6100..8a65db0 100644 --- a/app/Models/Loaders/GigsLoader.php +++ b/app/Models/Loaders/GigsLoader.php @@ -12,18 +12,18 @@ class GigsLoader $data = Event::select( "Event.Name as event", "Event.PlaceId as place_id", - "Place.Name as place", - "Place.Address as address", - "Place.Phone as phone", - "Place.Url as url", + "places.name as place", + "places.address as address", + "places.phone as phone", + "places.url as url", DB::Raw("DAY(Event.Date) as mday"), DB::Raw("MONTH(Event.Date) as month"), DB::Raw("DATE_FORMAT(Event.Time, '%H:%s') as time"), DB::Raw("CONCAT(DATE_FORMAT(Event.Date,'%Y-%m-%d'), 'T',DATE_FORMAT(Event.Time, '%H:%i:%s')) as fulldate") - )->join("Place", function ($join){ - $join->on("Place.Id", "=", "Event.PlaceId") - ->where("Place.DeleteDate", NULL); + )->join("places", function ($join){ + $join->on("places.id", "=", "Event.PlaceId") + ->where("places.deleted_at", NULL); }); $data = $data->get(); diff --git a/app/Models/Loaders/UsersLoader.php b/app/Models/Loaders/UsersLoader.php index 19efed2..1bd1c3e 100644 --- a/app/Models/Loaders/UsersLoader.php +++ b/app/Models/Loaders/UsersLoader.php @@ -2,18 +2,24 @@ namespace App\Models\Loaders; -use App\Models\ORM\User; +use App\Models\ORM\User as Contact; class UsersLoader { public function getContacts(): array { - $data = User::select( - "users.id","users.login","users.firstName","users.lastName", - "users.phone", "users.email", "users.vkcom as webPage", - "users.img_large","users.img_small","contactRoles.name as role" - )->join("contactRoles", "users.contactRole", "=", "contactRoles.id") - ->where("users.useAsContact", 1) + $data = Contact::select( + "users.id", + "users.name as first_name", + "users.last_name", + "users.phone", + "users.email", + "users.vk_id as web_page", + "users.img_large", + "users.img_small", + "contact_roles.description as role" + )->join("contact_roles", "users.contact_role", "=", "contact_roles.id") + ->where("users.use_as_contact", 1) ->get(); return $data ? $data->toArray() : []; diff --git a/app/Models/ORM/ContactRole.php b/app/Models/ORM/ContactRole.php new file mode 100644 index 0000000..6fc0afc --- /dev/null +++ b/app/Models/ORM/ContactRole.php @@ -0,0 +1,14 @@ +id = $attributes['id'] ?? null; - $this->login = $attributes['login']; - $this->firstName = $attributes['firstName']; - $this->lastName = $attributes['lastName']; + $this->firstName = $attributes['first_name']; + $this->lastName = $attributes['last_name']; $this->phone = $attributes['phone']; $this->email = $attributes['email']; - $this->webPage = $attributes['webPage'] ?? null; + $this->webPage = $attributes['web_page'] ?? null; $this->role = $attributes['role'] ?? null; $this->imgSmall = $this->setImagePath($attributes['img_small']) ?? null; $this->imgLarge = $this->setImagePath($attributes['img_large']) ?? null; @@ -88,11 +86,6 @@ class Contact return $this->id; } - public function getLogin(): string - { - return $this->login; - } - public function getFirstName(): string { return $this->firstName; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..f538295 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -19,6 +20,6 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + Paginator::useTailwind(); } } diff --git a/composer.json b/composer.json index f724d6f..adad833 100755 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ }, "require-dev": { "fakerphp/faker": "^1.23", + "laravel/breeze": "^2.4", "laravel/pail": "^1.2.2", "laravel/pint": "^1.24", "laravel/sail": "^1.41", @@ -86,4 +87,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..12a9bdb 100755 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -11,12 +11,27 @@ return new class extends Migration */ public function up(): void { + Schema::create('contact_roles', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->string('description')->nullable(); + $table->timestamp('created_at')->default(now()); + $table->timestamp('updated_at')->useCurrent(); + }); + Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); + $table->string('last_name')->nullable(); + $table->string('phone')->nullable(); + $table->string('vk_id')->nullable(); $table->string('email')->unique(); + $table->boolean('use_as_contact')->default(false); + $table->integer('contact_role')->default(0); + $table->string('img_small')->nullable(); + $table->string('img_large')->nullable(); $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); + $table->string('password')->nullable(); $table->rememberToken(); $table->timestamps(); }); @@ -42,6 +57,7 @@ return new class extends Migration */ public function down(): void { + Schema::dropIfExists('contact_roles'); Schema::dropIfExists('users'); Schema::dropIfExists('password_reset_tokens'); Schema::dropIfExists('sessions'); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6b901f8..144a779 100755 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,7 +2,7 @@ namespace Database\Seeders; -use App\Models\User; +use App\Models\ORM\ContactRole; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -17,9 +17,13 @@ class DatabaseSeeder extends Seeder { // User::factory(10)->create(); - User::factory()->create([ - 'name' => 'Test User', - 'email' => 'test@example.com', + ContactRole::insert([ + [ 'name' => 'tech', 'description' => 'Технические вопросы' ], + [ 'name' => 'org', 'description' => 'Организация концертов' ] + ]); + + $this->call([ + UserSeeder::class, ]); } } diff --git a/package.json b/package.json index 7686b29..2ea7e1d 100755 --- a/package.json +++ b/package.json @@ -7,11 +7,15 @@ "dev": "vite" }, "devDependencies": { + "@tailwindcss/forms": "^0.5.2", "@tailwindcss/vite": "^4.0.0", + "alpinejs": "^3.4.2", + "autoprefixer": "^10.4.2", "axios": "^1.11.0", "concurrently": "^9.0.1", "laravel-vite-plugin": "^2.0.0", - "tailwindcss": "^4.0.0", + "postcss": "^8.4.31", + "tailwindcss": "^3.1.0", "vite": "^7.0.7" } } diff --git a/resources/css/app.css b/resources/css/app.css index 3e6abea..b5c61c9 100755 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,11 +1,3 @@ -@import 'tailwindcss'; - -@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php'; -@source '../../storage/framework/views/*.php'; -@source '../**/*.blade.php'; -@source '../**/*.js'; - -@theme { - --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', - 'Segoe UI Symbol', 'Noto Color Emoji'; -} +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/resources/js/app.js b/resources/js/app.js index e59d6a0..a8093be 100755 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1 +1,7 @@ import './bootstrap'; + +import Alpine from 'alpinejs'; + +window.Alpine = Alpine; + +Alpine.start(); diff --git a/resources/views/places/index.blade.php b/resources/views/places/index.blade.php new file mode 100644 index 0000000..a0c7ec5 --- /dev/null +++ b/resources/views/places/index.blade.php @@ -0,0 +1,81 @@ +@push('scripts') + +@endpush + + +

+ {{ __('Концертные площадки') }} +

+
+ +
+
+
+
+ +
+ + + + + + + + + + + + @foreach($places as $place) + + + + + + + + @endforeach + +
IDНазваниеАдресТелефонКарта
{{ $place->id }} + {{ $place->name }} + {{ $place->address }}{{ $place->phone }} + + + + + +
+ +
+ {{ $places->links() }} +
+
+
+
+
+
+
+ + diff --git a/routes/web.php b/routes/web.php index 1557eba..d4831d9 100755 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ middleware(['auth', 'verified'])->name('dashboard'); + +Route::middleware('auth')->group(function () { + Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); + Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update'); + Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); +}); + +Route::middleware('auth') + ->group(function () { + Route::get('/places', [PlacesController::class, 'index'])->name('places.index'); + Route::patch('/places', [PlacesController::class, 'update'])->name('places.update'); + Route::post('/places', [PlacesController::class, 'create'])->name('places.create'); + Route::delete('/places', [PlacesController::class, 'delete'])->name('places.delete'); +}); Route::get('/', [MainController::class, 'index']); Route::get('/rider', [RiderController::class, 'index']); @@ -22,3 +46,4 @@ Route::get('/contacts', [ContactsController::class, 'index']); Route::get('/map/index/id/{id}', [ MapController::class, 'index' ]); Route::get('/api/getplace/id/{id}', [ MapController::class, 'getPlace' ]); +require __DIR__.'/auth.php'; diff --git a/vite.config.js b/vite.config.js index f35b4e7..421b569 100755 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,5 @@ import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; -import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ plugins: [ @@ -8,11 +7,5 @@ export default defineConfig({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), - tailwindcss(), ], - server: { - watch: { - ignored: ['**/storage/framework/views/**'], - }, - }, });