This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #13 - create basic view, controller, service, routing * #13 - create event, modify previous commit, fix * #13 - fix * #13 - Apply suggestions from code review Co-authored-by: Kamil Piech <[email protected]> * #13 - changes after review * #13 - fix blade newline * #13 - cs:fix after merge * #13 - Apply suggestions from code review Co-authored-by: Kamil Piech <[email protected]> * #13 - fix after apply suggestions * #13 - fix after review Co-authored-by: Kamil Piech <[email protected]>
- Loading branch information
1 parent
dd6b610
commit 30fa3ed
Showing
13 changed files
with
176 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@component('mail::message') | ||
<h3>Hello {{$receiver}}</h3> | ||
<p>You have received an email from: {{ $sender->name }}</p> | ||
<p>Email: {{ $sender->email }}</p> | ||
<p>You are invited to meetup page</p> | ||
@component('mail::button', ['url' => route("register", ["email" => $receiver])]) | ||
<p>Click here to register</p> | ||
@endcomponent | ||
@endcomponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@extends('layouts.app') | ||
|
||
@section('content') | ||
<div class="container md:w-[800px] mx-auto"> | ||
@auth | ||
<form action="{{ route('invitation.store') }}" method="post" enctype="multipart/form-data" | ||
class="bg-white p-6 mt-20 rounded-20 shadow-xl"> | ||
@csrf | ||
<div> | ||
@if(session()->has('message')) | ||
<div> | ||
{{ session()->get('message') }} | ||
</div> | ||
@endif | ||
<div> | ||
<h3 class="text-xl leading-6 font-medium text-gray-900"> | ||
Invite User | ||
</h3> | ||
</div> | ||
<div class="mt-6 flex flex-col gap-7"> | ||
<div> | ||
<label for="email" class="block font-medium text-gray-700"> | ||
</label> | ||
<div class="mt-1"> | ||
<input type="email" name="email" id="email" placeholder="Email" value="{{ old('email') }}" | ||
class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" /> | ||
<x-input-error for="email" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="pt-6"> | ||
<div class="flex justify-end"> | ||
<a href="{{ route("meetups") }}" | ||
class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | ||
Cancel | ||
</a> | ||
<button type="submit" | ||
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
</form> | ||
@endauth | ||
</div> | ||
@endsection |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Http\Controllers; | ||
|
||
use Blumilk\Meetup\Core\Http\Requests\Invitations\StoreInvitationRequest; | ||
use Blumilk\Meetup\Core\Models\User; | ||
use Blumilk\Meetup\Core\Services\InvitationsService; | ||
use Illuminate\Contracts\Auth\Guard; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Http\RedirectResponse; | ||
|
||
class InvitationController extends Controller | ||
{ | ||
public function create(): View | ||
{ | ||
return view("invitation"); | ||
} | ||
|
||
public function store(StoreInvitationRequest $request, InvitationsService $service, Guard $auth): RedirectResponse | ||
{ | ||
if (User::query()->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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Http\Requests\Invitations; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class StoreInvitationRequest extends FormRequest | ||
{ | ||
public function rules(): array | ||
{ | ||
return [ | ||
"email" => ["required", "email"], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Notifications; | ||
|
||
use Blumilk\Meetup\Core\Models\User; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class InvitationEmailNotification extends Notification | ||
{ | ||
use Queueable; | ||
|
||
public function __construct( | ||
protected User $sender, | ||
protected string $email, | ||
) {} | ||
|
||
public function via(): array | ||
{ | ||
return ["mail"]; | ||
} | ||
|
||
public function toMail(): MailMessage | ||
{ | ||
return (new MailMessage()) | ||
->replyTo($this->email) | ||
->markdown( | ||
"emails.invitation", | ||
[ | ||
"receiver" => $this->email, | ||
"sender" => $this->sender, | ||
], | ||
); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Meetup\Core\Services; | ||
|
||
use Blumilk\Meetup\Core\Models\User; | ||
use Blumilk\Meetup\Core\Notifications\InvitationEmailNotification; | ||
|
||
class InvitationsService | ||
{ | ||
public function sendInvitation(User $senderUser, string $email): void | ||
{ | ||
$senderUser->notify(new InvitationEmailNotification($senderUser, $email)); | ||
} | ||
} |