Skip to content

Commit 62fc749

Browse files
Merge pull request #49 from khalidmaquilang/dev
v2.0.0
2 parents 2b7c948 + a99ceb9 commit 62fc749

File tree

81 files changed

+2021
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2021
-405
lines changed

README.md

Lines changed: 71 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,71 @@
1-
<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>
2-
3-
<p align="center">
4-
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8-
</p>
9-
10-
## About Laravel
11-
12-
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:
13-
14-
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15-
- [Powerful dependency injection container](https://laravel.com/docs/container).
16-
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17-
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18-
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19-
- [Robust background job processing](https://laravel.com/docs/queues).
20-
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21-
22-
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23-
24-
## Learning Laravel
25-
26-
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.
27-
28-
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29-
30-
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.
31-
32-
## Laravel Sponsors
33-
34-
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).
35-
36-
### Premium Partners
37-
38-
- **[Vehikl](https://vehikl.com/)**
39-
- **[Tighten Co.](https://tighten.co)**
40-
- **[WebReinvent](https://webreinvent.com/)**
41-
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
42-
- **[64 Robots](https://64robots.com)**
43-
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
44-
- **[Cyber-Duck](https://cyber-duck.co.uk)**
45-
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
46-
- **[Jump24](https://jump24.co.uk)**
47-
- **[Redberry](https://redberry.international/laravel/)**
48-
- **[Active Logic](https://activelogic.com)**
49-
- **[byte5](https://byte5.de)**
50-
- **[OP.GG](https://op.gg)**
51-
52-
## Contributing
53-
54-
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55-
56-
## Code of Conduct
57-
58-
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).
59-
60-
## Security Vulnerabilities
61-
62-
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.
63-
64-
## License
65-
66-
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
1+
## Requirements
2+
3+
- php: 8.3
4+
- Node: 20
5+
6+
## Setup on local
7+
8+
- Copy .env file
9+
10+
````
11+
cp .env.example .env
12+
````
13+
14+
- Edit mysql connection in your .env (credential is based on your sql server)
15+
16+
```
17+
DB_CONNECTION=mysql
18+
DB_HOST=127.0.0.1
19+
DB_PORT=3306
20+
DB_DATABASE=laravel
21+
DB_USERNAME=root
22+
DB_PASSWORD=password
23+
```
24+
25+
- Run ``composer install``
26+
- Run ``npm install``
27+
- Run ``php artisan key:generate``
28+
- Run ``php artisan migrate``
29+
- Run ``php artisan shield:generate --all --option=permissions``
30+
- Run ``php artisan serve``
31+
- Run ``npm run dev`` (another window)
32+
- Open ``localhost`` on your browser
33+
34+
## Setup on local using sail
35+
36+
- Install Docker https://laravel.com/docs/11.x/installation#docker-installation-using-sail
37+
- Copy .env file
38+
39+
````
40+
cp .env.example .env
41+
````
42+
43+
- Edit mysql connection in your .env (credential is based on your sql server)
44+
45+
```
46+
DB_CONNECTION=mysql
47+
DB_HOST=mysql
48+
DB_PORT=3306
49+
DB_DATABASE=laravel
50+
DB_USERNAME=sail
51+
DB_PASSWORD=password
52+
```
53+
54+
- Run this command
55+
56+
````
57+
docker run --rm \
58+
-u "$(id -u):$(id -g)" \
59+
-v "$(pwd):/var/www/html" \
60+
-w /var/www/html \
61+
laravelsail/php83-composer:latest \
62+
composer install --ignore-platform-reqs
63+
````
64+
65+
- Run ``./vendor/bin/sail up -d`` to build and start the container
66+
- Run ``./vendor/bin/sail npm install``
67+
- Run ``./vendor/bin/sail artisan key:generate``
68+
- Run ``./vendor/bin/sail artisan migrate --seed``
69+
- Run ``./vendor/bin/sail artisan shield:generate --all --option=permissions``
70+
- Run ``./vendor/bin/sail npm run dev``
71+
- Open ``localhost`` on your browser
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<?php
2+
3+
namespace App\Filament\Pages;
4+
5+
use App\Models\Invite;
6+
use Filament\Actions\Action;
7+
use Filament\Actions\ActionGroup;
8+
use Filament\Facades\Filament;
9+
use Filament\Forms\Components\Component;
10+
use Filament\Forms\Components\TextInput;
11+
use Filament\Forms\Form;
12+
use Filament\Http\Responses\Auth\Contracts\RegistrationResponse;
13+
use Filament\Pages\Concerns\InteractsWithFormActions;
14+
use Filament\Pages\SimplePage;
15+
use Illuminate\Auth\EloquentUserProvider;
16+
use Illuminate\Auth\Events\Registered;
17+
use Illuminate\Auth\SessionGuard;
18+
use Illuminate\Support\Facades\Hash;
19+
use Illuminate\Validation\Rules\Password;
20+
use Livewire\Attributes\Url;
21+
22+
class RegisterInvited extends SimplePage
23+
{
24+
use InteractsWithFormActions;
25+
26+
protected static bool $shouldRegisterNavigation = false;
27+
28+
protected static string $view = 'filament-panels::pages.auth.register';
29+
30+
#[Url]
31+
public $token = '';
32+
33+
public ?Invite $invite = null;
34+
35+
public ?array $data = [];
36+
37+
/**
38+
* @return void
39+
*/
40+
public function mount(): void
41+
{
42+
$this->invite = Invite::where('code', $this->token)->firstOrFail();
43+
44+
$this->form->fill([
45+
'email' => $this->invite->email,
46+
]);
47+
}
48+
49+
public function form(Form $form): Form
50+
{
51+
return $form;
52+
}
53+
54+
/**
55+
* @return array<int | string, string | Form>
56+
*/
57+
protected function getForms(): array
58+
{
59+
return [
60+
'form' => $this->form(
61+
$this->makeForm()
62+
->schema([
63+
$this->getNameFormComponent(),
64+
$this->getEmailFormComponent(),
65+
$this->getPasswordFormComponent(),
66+
$this->getPasswordConfirmationFormComponent(),
67+
])
68+
->statePath('data'),
69+
),
70+
];
71+
}
72+
73+
protected function getNameFormComponent(): Component
74+
{
75+
return TextInput::make('name')
76+
->label(__('filament-panels::pages/auth/register.form.name.label'))
77+
->required()
78+
->maxLength(255)
79+
->autofocus();
80+
}
81+
82+
protected function getEmailFormComponent(): Component
83+
{
84+
return TextInput::make('email')
85+
->label(__('filament-panels::pages/auth/register.form.email.label'))
86+
->email()
87+
->required()
88+
->maxLength(255)
89+
->unique($this->getUserModel())
90+
->dehydrated()
91+
->readOnly();
92+
}
93+
94+
protected function getPasswordFormComponent(): Component
95+
{
96+
return TextInput::make('password')
97+
->label(__('filament-panels::pages/auth/register.form.password.label'))
98+
->password()
99+
->revealable(filament()->arePasswordsRevealable())
100+
->required()
101+
->rule(Password::default())
102+
->dehydrateStateUsing(fn ($state) => Hash::make($state))
103+
->same('passwordConfirmation')
104+
->validationAttribute(__('filament-panels::pages/auth/register.form.password.validation_attribute'));
105+
}
106+
107+
protected function getPasswordConfirmationFormComponent(): Component
108+
{
109+
return TextInput::make('passwordConfirmation')
110+
->label(__('filament-panels::pages/auth/register.form.password_confirmation.label'))
111+
->password()
112+
->revealable(filament()->arePasswordsRevealable())
113+
->required()
114+
->dehydrated(false);
115+
}
116+
117+
public function loginAction(): \Filament\Actions\Action
118+
{
119+
return Action::make('login')
120+
->link()
121+
->label(__('filament-panels::pages/auth/register.actions.login.label'))
122+
->url(filament()->getLoginUrl());
123+
}
124+
125+
protected function getUserModel(): string
126+
{
127+
if (isset($this->userModel)) {
128+
return $this->userModel;
129+
}
130+
131+
/** @var SessionGuard $authGuard */
132+
$authGuard = Filament::auth();
133+
134+
/** @var EloquentUserProvider $provider */
135+
$provider = $authGuard->getProvider();
136+
137+
return $this->userModel = $provider->getModel();
138+
}
139+
140+
public function register(): ?RegistrationResponse
141+
{
142+
$company = $this->invite->company;
143+
144+
$roles = $this->invite->roles;
145+
$data = $this->form->getState();
146+
$user = $this->getUserModel()::create($data);
147+
148+
$this->invite->delete();
149+
150+
event(new Registered($user));
151+
152+
$company->members()->attach($user);
153+
Filament::auth()->login($user);
154+
setPermissionsTeamId($company->id);
155+
156+
$user->syncRoles($roles);
157+
158+
session()->regenerate();
159+
160+
return app(RegistrationResponse::class);
161+
}
162+
163+
/**
164+
* @return array<\Filament\Actions\Action | ActionGroup>
165+
*/
166+
protected function getFormActions(): array
167+
{
168+
return [
169+
$this->getRegisterFormAction(),
170+
];
171+
}
172+
173+
public function getRegisterFormAction(): Action
174+
{
175+
return Action::make('register')
176+
->label(__('filament-panels::pages/auth/register.form.actions.register.label'))
177+
->submit('register');
178+
}
179+
180+
protected function hasFullWidthFormActions(): bool
181+
{
182+
return true;
183+
}
184+
}

0 commit comments

Comments
 (0)