Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Native implementation of Laravel Jetstream Features using Filament components. #21

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/stephenjude/filament-jetstream/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/stephenjude/filament-jetstream/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/stephenjude/filament-jetstream.svg?style=flat-square)](https://packagist.org/packages/stephenjude/filament-jetstream)

This package seamlessly integrates all Laravel Jetstream features into your Filament application. Similar to Laravel Jetstream, it's designed for installation exclusively on a fresh Laravel application. There's no need to install Livewire, Jetstream, or Filament separately before using this package – it handles all the setup for you!
This package seamlessly integrates all Laravel Jetstream features into your Filament application. Similar to Laravel
Jetstream, it's designed for installation exclusively on a fresh Laravel application, and you can also install it on an
existing application.

## How It Works

Expand All @@ -33,23 +35,15 @@ You can remove the `--teams` and `--api` arguments if you don't want those featu

## Screenshots

![Edit Profile](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/profile_1.png)
![Profile](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/profile.jpeg)

---

![Edit Profile](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/profile_2.png)
![API Tokens](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/api_tokens.jpeg)

---

![Edit Team](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/team_1.png)

---

![Edit Team](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/team_2.png)

---

![Edit Team](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/api_token.png)
![Team](https://raw.githubusercontent.com/stephenjude/filament-jetstream/main/art/team.jpeg)

## Testing

Expand Down
Binary file removed art/api_token.png
Binary file not shown.
Binary file added art/api_tokens.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/delete_account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/delete_api_token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/logout_browser_session.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/manage_api_permission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/manage_role.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/profile.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed art/profile_1.png
Binary file not shown.
Binary file removed art/profile_2.png
Binary file not shown.
Binary file added art/team.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed art/team_1.png
Binary file not shown.
Binary file removed art/team_2.png
Binary file not shown.
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
],
"require": {
"php": "^8.1",
"bacon/bacon-qr-code": "^3.0",
"filament/filament": "^3.0",
"laravel/jetstream": "^4.2|^5.0",
"illuminate/contracts": "^10.0|^11.0",
"laravel/sanctum": "^4.0",
"mobiledetect/mobiledetectlib": "^4.8",
"pragmarx/google2fa": "^8.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
Expand All @@ -40,12 +43,12 @@
},
"autoload": {
"psr-4": {
"FilamentJetstream\\FilamentJetstream\\": "src/"
"Filament\\Jetstream\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"FilamentJetstream\\FilamentJetstream\\Tests\\": "tests/"
"Filament\\Jetstream\\Tests\\": "tests/"
}
},
"scripts": {
Expand All @@ -65,7 +68,7 @@
"extra": {
"laravel": {
"providers": [
"FilamentJetstream\\FilamentJetstream\\FilamentJetstreamServiceProvider"
"Filament\\Jetstream\\JetstreamServiceProvider"
]
}
},
Expand Down
72 changes: 72 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Database\Factories;

use App\Models\User;
use Filament\Jetstream\Features;
use Filament\Jetstream\Models\Team;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\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'),
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'remember_token' => Str::random(10),
'profile_photo_path' => null,
'current_team_id' => null,
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}

/**
* Indicate that the user should have a personal team.
*/
public function withPersonalTeam(?callable $callback = null): static
{
if (! Features::hasTeamFeatures()) {
return $this->state([]);
}

return $this->has(
Team::factory()
->state(fn (array $attributes, User $user) => [
'name' => $user->name . '\'s Team',
'user_id' => $user->id,
'personal_team' => true,
])
->when(is_callable($callback), $callback),
'ownedTeams'
);
}
}
52 changes: 52 additions & 0 deletions database/migrations/create_team_tables.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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('teams', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->index();
$table->string('name');
$table->boolean('personal_team');
$table->timestamps();
});

Schema::create('team_user', function (Blueprint $table) {
$table->id();
$table->foreignId('team_id');
$table->foreignId('user_id');
$table->string('role')->nullable();
$table->timestamps();

$table->unique(['team_id', 'user_id']);
});

Schema::create('team_invitations', function (Blueprint $table) {
$table->id();
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
$table->string('email');
$table->string('role')->nullable();
$table->timestamps();

$table->unique(['team_id', 'email']);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('teams');
Schema::dropIfExists('team_user');
Schema::dropIfExists('team_invitations');
}
};
51 changes: 51 additions & 0 deletions database/migrations/create_user_tables.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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->foreignId('current_team_id')->nullable();
$table->string('profile_photo_path', 2048)->nullable();
$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');
}
};
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
backupStaticProperties="false"
>
<testsuites>
<testsuite name="FilamentJetstream Test Suite">
<testsuite name="Filament Jetstream Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
Loading