-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added contacts page to client resource
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 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
85 changes: 85 additions & 0 deletions
85
app/Filament/Resources/ClientResource/Pages/ClientContacts.php
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,85 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\ClientResource\Pages; | ||
|
||
use App\Filament\Resources\ClientResource; | ||
use AymanAlhattami\FilamentPageWithSidebar\Traits\HasPageSidebar; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Pages\ManageRelatedRecords; | ||
use Filament\Tables\Actions\BulkActionGroup; | ||
use Filament\Tables\Actions\CreateAction; | ||
use Filament\Tables\Actions\DeleteAction; | ||
use Filament\Tables\Actions\DeleteBulkAction; | ||
use Filament\Tables\Actions\EditAction; | ||
use Filament\Tables\Actions\ForceDeleteAction; | ||
use Filament\Tables\Actions\ForceDeleteBulkAction; | ||
use Filament\Tables\Actions\RestoreAction; | ||
use Filament\Tables\Actions\RestoreBulkAction; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Columns\ToggleColumn; | ||
use Filament\Tables\Table; | ||
use Illuminate\Contracts\Support\Htmlable; | ||
|
||
class ClientContacts extends ManageRelatedRecords | ||
{ | ||
use HasPageSidebar; | ||
|
||
protected static string $resource = ClientResource::class; | ||
|
||
protected static string $relationship = 'contacts'; | ||
|
||
public function getTitle(): string|Htmlable | ||
{ | ||
return __('Contacts'); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
|
||
])->columns(1); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('title') | ||
->columns([ | ||
TextColumn::make('name') | ||
->label(__('Name')), | ||
|
||
TextColumn::make('position') | ||
->label(__('Position')), | ||
|
||
ToggleColumn::make('active') | ||
->label(__('Active')), | ||
|
||
TextColumn::make('email') | ||
->label(__('Email')), | ||
|
||
TextColumn::make('phone') | ||
->label(__('Phone')), | ||
|
||
TextColumn::make('last_login_at') | ||
->label(__('Last Login at')) | ||
->dateTime() | ||
]) | ||
->headerActions([ | ||
CreateAction::make(), | ||
]) | ||
->actions([ | ||
EditAction::make(), | ||
DeleteAction::make(), | ||
ForceDeleteAction::make(), | ||
RestoreAction::make(), | ||
]) | ||
->bulkActions([ | ||
BulkActionGroup::make([ | ||
DeleteBulkAction::make(), | ||
RestoreBulkAction::make(), | ||
ForceDeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
class Contact extends BaseModel | ||
{ | ||
use HasFactory; | ||
|
||
public function client(): BelongsTo | ||
{ | ||
return $this->belongsTo(Client::class); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
database/migrations/2024_10_09_180357_create_contacts_table.php
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,37 @@ | ||
<?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('contacts', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('position')->nullable(); | ||
$table->string('email')->nullable(); | ||
$table->string('password')->nullable(); | ||
$table->boolean('primary_contact')->default(false); | ||
$table->string('phone')->nullable(); | ||
$table->unsignedInteger('client_id')->nullable(); | ||
$table->boolean('active')->default(false); | ||
$table->timestamp('last_login_at')->nullable(); | ||
$table->unsignedInteger('organisation_id'); | ||
$table->softDeletes(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('contacts'); | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
resources/views/filament/resources/client-resource/pages/client-contacts.blade.php
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,3 @@ | ||
<x-filament-panels::page> | ||
|
||
</x-filament-panels::page> |