-
diff --git a/src/Http/Controllers/Auth/EmailVerificationController.php b/src/Http/Controllers/Auth/EmailVerificationController.php
old mode 100644
new mode 100755
index 54a7be36..c589f485
--- a/src/Http/Controllers/Auth/EmailVerificationController.php
+++ b/src/Http/Controllers/Auth/EmailVerificationController.php
@@ -21,7 +21,7 @@ public function store(EmailVerificationRequest $request): RedirectResponse
{
$request->fulfill();
- return redirect()->route("home");
+ return redirect()->route("meetups");
}
public function notification(Request $request): RedirectResponse
diff --git a/src/Http/Controllers/Auth/RegisterController.php b/src/Http/Controllers/Auth/RegisterController.php
index 2efc09d8..1ba7a91a 100644
--- a/src/Http/Controllers/Auth/RegisterController.php
+++ b/src/Http/Controllers/Auth/RegisterController.php
@@ -14,7 +14,11 @@ class RegisterController extends Controller
{
public function create(): View
{
- return view("user.register");
+ if (request()->has("email")) {
+ return view("user.register")->with("email", request()->get("email"));
+ }
+
+ return view("user.register")->with("email", old("email"));
}
public function store(RegisterUserRequest $request): View
diff --git a/src/Http/Controllers/InvitationController.php b/src/Http/Controllers/InvitationController.php
new file mode 100755
index 00000000..123df70d
--- /dev/null
+++ b/src/Http/Controllers/InvitationController.php
@@ -0,0 +1,31 @@
+where("email", $request->validated("email"))->exists()) {
+ return back()->with("message", "User with that email already existed");
+ }
+
+ $service->sendInvitation($auth->user(), $request->validated("email"));
+
+ return back()->with("message", "We have sent invitation");
+ }
+}
diff --git a/src/Http/Requests/Invitations/StoreInvitationRequest.php b/src/Http/Requests/Invitations/StoreInvitationRequest.php
new file mode 100755
index 00000000..cf2dcf22
--- /dev/null
+++ b/src/Http/Requests/Invitations/StoreInvitationRequest.php
@@ -0,0 +1,17 @@
+ ["required", "email"],
+ ];
+ }
+}
diff --git a/src/Http/Routing/WebRouting.php b/src/Http/Routing/WebRouting.php
old mode 100644
new mode 100755
index f492ac7d..df7c02b2
--- a/src/Http/Routing/WebRouting.php
+++ b/src/Http/Routing/WebRouting.php
@@ -4,11 +4,13 @@
namespace Blumilk\Meetup\Core\Http\Routing;
+use Blumilk\Meetup\Core\Http\Controllers\Auth\EmailVerificationController;
use Blumilk\Meetup\Core\Http\Controllers\Auth\LoginController;
use Blumilk\Meetup\Core\Http\Controllers\Auth\PasswordResetController;
use Blumilk\Meetup\Core\Http\Controllers\Auth\RegisterController;
use Blumilk\Meetup\Core\Http\Controllers\Auth\SocialiteController;
use Blumilk\Meetup\Core\Http\Controllers\ContactController;
+use Blumilk\Meetup\Core\Http\Controllers\InvitationController;
use Blumilk\Meetup\Core\Http\Controllers\MeetupController;
use Blumilk\Meetup\Core\Http\Controllers\NewsletterSubscriberController;
use Blumilk\Meetup\Core\Http\Controllers\OrganizationController;
@@ -33,7 +35,7 @@ public function wire(): void
$this->router->get("/auth/logout", "logout")->middleware("auth")->name("logout");
});
- $this->router->controller(PasswordResetController::class)->group(function (): void {
+ $this->router->controller(EmailVerificationController::class)->group(function (): void {
$this->router->get("/email/verify", "create")->middleware("auth")->name("verification.notice");
$this->router->get("/email/verify/{id}/{hash}", "store")->middleware(["auth", "signed"])->name("verification.verify");
$this->router->post("/email/verification-notification", "notification")->middleware(["auth", "throttle:web"])->name("verification.send");
@@ -102,6 +104,11 @@ public function wire(): void
$this->router->post("/newsletter/unsubscribe", "destroy")->name("newsletter.destroy");
});
+ $this->router->controller(InvitationController::class)->group(function (): void {
+ $this->router->get("/invitation", "create")->middleware("auth")->name("invitation");
+ $this->router->post("/invitation", "store")->name("invitation.store");
+ });
+
$this->router->controller(StaticController::class)->group(function (): void {
$this->router->get("/static/{path}", "index")->where("path", ".*")->name("assets");
});
diff --git a/src/Notifications/InvitationEmailNotification.php b/src/Notifications/InvitationEmailNotification.php
new file mode 100755
index 00000000..6dd73a84
--- /dev/null
+++ b/src/Notifications/InvitationEmailNotification.php
@@ -0,0 +1,38 @@
+replyTo($this->email)
+ ->markdown(
+ "emails.invitation",
+ [
+ "receiver" => $this->email,
+ "sender" => $this->sender,
+ ],
+ );
+ }
+}
diff --git a/src/Providers/EventServiceProvider.php b/src/Providers/EventServiceProvider.php
old mode 100644
new mode 100755
diff --git a/src/Services/InvitationsService.php b/src/Services/InvitationsService.php
new file mode 100755
index 00000000..625ef0cd
--- /dev/null
+++ b/src/Services/InvitationsService.php
@@ -0,0 +1,16 @@
+notify(new InvitationEmailNotification($senderUser, $email));
+ }
+}
From b24753d17d84115d155b9af90a0b0a9075d28526 Mon Sep 17 00:00:00 2001
From: Aleksander Kowalski
Date: Fri, 6 May 2022 14:24:44 +0200
Subject: [PATCH 9/9] #14 - crud for news (#39)
* feat: add blades
* feat: add
* fix: refactor routing
* feat: add editor and remove tests
* feat: cleaning
* fix: after review
* fix: cleaning
* fix: after review and dump error
* fix: remove files
* Update resources/css/app.css
Co-authored-by: Kamil Piech
* fix: after review
* fix: after review
* fix: remove purifier
* fix: after review
* feat: update routing and fixed bug
* fix: after review
* fix: after review
* fix: change chmod
* fix: eslint run
Co-authored-by: Kamil Piech
Co-authored-by: aleksander.kowalski
---
.gitignore | 1 +
config/app.php | 1 +
.../2022_03_18_195003_create_news_table.php | 26 +++++++++
database/seeders/DummyDataSeeder.php | 3 +-
package.json | 2 +
resources/js/app.js | 28 ++++++++++
resources/static/.gitignore | 2 +-
.../views/components/form-input.blade.php | 0
resources/views/meetups/create.blade.php | 0
resources/views/meetups/edit.blade.php | 0
resources/views/meetups/index.blade.php | 2 +-
resources/views/news/create.blade.php | 29 ++++++++++
resources/views/news/edit.blade.php | 31 +++++++++++
resources/views/news/index.blade.php | 30 ++++++++++
resources/views/organizations/edit.blade.php | 0
resources/views/speakers/edit.blade.php | 0
src/Http/Controllers/NewsController.php | 55 +++++++++++++++++++
src/Http/Requests/News/NewsRequest.php | 25 +++++++++
src/Http/Routing/WebRouting.php | 10 ++++
src/Models/News.php | 16 +++++-
src/Models/User.php | 5 ++
tests/manual/public/index.php | 0
webpack.mix.js | 2 +-
23 files changed, 261 insertions(+), 7 deletions(-)
create mode 100644 database/migrations/2022_03_18_195003_create_news_table.php
mode change 100755 => 100644 resources/views/components/form-input.blade.php
mode change 100755 => 100644 resources/views/meetups/create.blade.php
mode change 100755 => 100644 resources/views/meetups/edit.blade.php
create mode 100644 resources/views/news/create.blade.php
create mode 100644 resources/views/news/edit.blade.php
create mode 100644 resources/views/news/index.blade.php
mode change 100755 => 100644 resources/views/organizations/edit.blade.php
mode change 100755 => 100644 resources/views/speakers/edit.blade.php
create mode 100644 src/Http/Controllers/NewsController.php
create mode 100644 src/Http/Requests/News/NewsRequest.php
mode change 100644 => 100755 tests/manual/public/index.php
diff --git a/.gitignore b/.gitignore
index 8b6c26d4..ee9bd190 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ storage/redis/dump.rdb
/storage/src/*
composer.lock
package-lock.json
+yarn.lock
diff --git a/config/app.php b/config/app.php
index f125a881..227d1889 100755
--- a/config/app.php
+++ b/config/app.php
@@ -52,5 +52,6 @@
"Auth" => Illuminate\Support\Facades\Auth::class,
"Constants" => Blumilk\Meetup\Core\Models\Utils\Constants::class,
"AvailableNewsletter" => Blumilk\Meetup\Core\Enums\AvailableNewsletter::class,
+ "Str" => Illuminate\Support\Str::class,
],
];
diff --git a/database/migrations/2022_03_18_195003_create_news_table.php b/database/migrations/2022_03_18_195003_create_news_table.php
new file mode 100644
index 00000000..26ac37c9
--- /dev/null
+++ b/database/migrations/2022_03_18_195003_create_news_table.php
@@ -0,0 +1,26 @@
+id();
+ $table->foreignId("author_id")->constrained()->onDelete("cascade");
+ $table->string("title");
+ $table->longText("text");
+ $table->string("slug")->unique();
+ $table->timestamps();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::dropIfExists("news");
+ }
+};
diff --git a/database/seeders/DummyDataSeeder.php b/database/seeders/DummyDataSeeder.php
index b348f216..48924842 100755
--- a/database/seeders/DummyDataSeeder.php
+++ b/database/seeders/DummyDataSeeder.php
@@ -11,7 +11,6 @@
use Blumilk\Meetup\Core\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Carbon;
-use Illuminate\Support\Facades\Hash;
class DummyDataSeeder extends Seeder
{
@@ -20,7 +19,7 @@ public function run(): void
$user = User::factory([
"name" => "Admin",
"email" => "admin@example.com",
- "password" => Hash::make("password"),
+ "password" => "password",
"email_verified_at" => Carbon::createFromDate(2022, 01, 01),
])->create();
diff --git a/package.json b/package.json
index d48897b6..bef764f7 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,8 @@
"eslint-plugin-tailwindcss": "^3.5.0"
},
"dependencies": {
+ "@toast-ui/editor": "^3.1.4",
+ "codemirror": "^5.65.2",
"alpinejs": "^3.9.6",
"cross-env": "^7.0.3",
"tailwindcss": "^3.0.23",
diff --git a/resources/js/app.js b/resources/js/app.js
index d41a043b..6ef53beb 100644
--- a/resources/js/app.js
+++ b/resources/js/app.js
@@ -1,4 +1,32 @@
import Alpine from 'alpinejs'
+import Editor from '@toast-ui/editor'
+import 'codemirror/lib/codemirror.css'
+import '@toast-ui/editor/dist/toastui-editor.css'
+
+const editor = new Editor({
+ el: document.querySelector('#editor'),
+ height: '400px',
+ initialEditType: 'markdown',
+ placeholder: 'Write something cool!',
+})
+
+if (document.querySelector('#createNews')) {
+ document.querySelector('#createNews').addEventListener('submit', event => {
+ event.preventDefault()
+ document.querySelector('#text').value = editor.getMarkdown()
+ event.target.submit()
+ })
+}
+
+if (document.querySelector('#editNews')) {
+ editor.setMarkdown(document.querySelector('#oldText').value)
+
+ document.querySelector('#editNews').addEventListener('submit', event => {
+ event.preventDefault()
+ document.querySelector('#text').value = editor.getMarkdown()
+ event.target.submit()
+ })
+}
window.Alpine = Alpine
diff --git a/resources/static/.gitignore b/resources/static/.gitignore
index bdaf036c..26f465c6 100644
--- a/resources/static/.gitignore
+++ b/resources/static/.gitignore
@@ -1,2 +1,2 @@
-css/*
js/*
+css/*
diff --git a/resources/views/components/form-input.blade.php b/resources/views/components/form-input.blade.php
old mode 100755
new mode 100644
diff --git a/resources/views/meetups/create.blade.php b/resources/views/meetups/create.blade.php
old mode 100755
new mode 100644
diff --git a/resources/views/meetups/edit.blade.php b/resources/views/meetups/edit.blade.php
old mode 100755
new mode 100644
diff --git a/resources/views/meetups/index.blade.php b/resources/views/meetups/index.blade.php
index e1463890..81c7fb2b 100644
--- a/resources/views/meetups/index.blade.php
+++ b/resources/views/meetups/index.blade.php
@@ -17,7 +17,7 @@
{{ $meetup->language }}
Edit
-