Skip to content

Commit

Permalink
update versi 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy-susanto committed Oct 9, 2023
1 parent 948225e commit 6210d43
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 79 deletions.
69 changes: 69 additions & 0 deletions app/Filament/Pages/Auth/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Filament\Pages\Auth;

use Filament\Pages\Page;
use Filament\Actions\Action;
use Filament\Forms\Components\Component;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Auth\Login as BaseLogin;
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Filament\Pages\Concerns\InteractsWithFormActions;

class Login extends BaseLogin
{
use InteractsWithFormActions;
use WithRateLimiting;
protected function getCredentialsFromFormData(array $data): array
{
return [
'name' => $data['name'],
'password' => $data['password'],
];
}

protected function getFormActions(): array
{
return [
$this->getAuthenticateFormAction(),
];
}

protected function hasFullWidthFormActions(): bool
{
return true;
}

protected function getNameFormComponent(): Component
{
return TextInput::make('name')
->label(__('Username'))
->required()
->autocomplete()
->autofocus()
->extraInputAttributes(['tabindex' => 1]);
}

protected function getForms(): array
{
return [
'form' => $this->form(
$this->makeForm()
->schema([
$this->getNameFormComponent(),
$this->getPasswordFormComponent(),
$this->getRememberFormComponent(),
])
->statePath('data'),
),
];
}


protected function getAuthenticateFormAction(): Action
{
return Action::make('authenticate')
->label(__('filament-panels::pages/auth/login.form.actions.authenticate.label'))
->submit('authenticate');
}
}
105 changes: 105 additions & 0 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class UserResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('pegawai_id')
->maxLength(65),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('email')
->email()
->maxLength(255),
Forms\Components\DateTimePicker::make('email_verified_at'),
Forms\Components\TextInput::make('password')
->password()
->required()
->maxLength(255),
Forms\Components\TextInput::make('google_id')
->maxLength(255),
Forms\Components\TextInput::make('theme')
->maxLength(255)
->default('default'),
Forms\Components\TextInput::make('theme_color')
->maxLength(255),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('pegawai_id')
->searchable(),
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('email')
->searchable(),
Tables\Columns\TextColumn::make('email_verified_at')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('google_id')
->searchable(),
Tables\Columns\TextColumn::make('theme')
->searchable(),
Tables\Columns\TextColumn::make('theme_color')
->searchable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
];
}
}
2 changes: 1 addition & 1 deletion app/Filament/Resources/UserResource/Pages/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateUser extends CreateRecord
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Resources/UserResource/Pages/EditUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;

protected function getActions(): array
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Resources/UserResource/Pages/ListUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace App\Filament\Resources\UserResource\Pages;

use App\Filament\Resources\UserResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;

protected function getActions(): array
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Expand Down
58 changes: 0 additions & 58 deletions app/Livewire/Auth/Login.php

This file was deleted.

11 changes: 7 additions & 4 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace App\Providers;

use Filament\Tables\Table;
use Filament\Facades\Filament;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Filament\Support\Facades\FilamentView;
use Illuminate\Contracts\View\View;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Table;
use Filament\Support\Facades\FilamentView;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -17,7 +18,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{

if (env(key: 'APP_ENV') =='local') {
URL::forceScheme(scheme:'https');
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers\Filament;

use App\Filament\Pages\Auth\Login;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
Expand All @@ -26,11 +27,14 @@ public function panel(Panel $panel): Panel
->default()
->id('admin')
->path('app')
->registration()
->spa()
->maxContentWidth('full')
->brandLogo(asset('image/logouinjambi.svg'))
->brandName('Presensi Pegawai')
->favicon(asset('image/favicon.svg'))
->font('Poppins')
->login()
->login(Login::class)
->colors([
'primary' => Color::Amber,
])
Expand Down
3 changes: 3 additions & 0 deletions resources/views/filament/pages/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<x-filament-panels::page>

</x-filament-panels::page>
21 changes: 10 additions & 11 deletions resources/views/vendor/filament-panels/components/logo.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
@php
$brandName = filament()->getBrandName();
$brandLogo = filament()->getBrandLogo()
$brandLogo = filament()->getBrandLogo();
@endphp

@if (filled($brandLogo))
<img
src="{{ $brandLogo }}"
loading="lazy"
alt="{{ $brandName }}"
{{ $attributes->class(['fi-logo h-10']) }}
/>
<div class="flex items-center border py-2 px-2 rounded-xl">
<img src="{{ $brandLogo }}" loading="lazy" alt="{{ $brandName }}"
{{ $attributes->class(['fi-logo h-10']) }} />
<div class="px-2">
<span class="font-bold">{{ $brandName }}</span>
</div>
</div>
@else
<div
{{ $attributes->class(['fi-logo text-xl font-bold leading-5 tracking-tight text-gray-950 dark:text-white']) }}
>
<div {{ $attributes->class(['fi-logo text-xl font-bold leading-5 tracking-tight text-gray-950 dark:text-white']) }}>
{{ $brandName }}
</div>
@endif
@endif

0 comments on commit 6210d43

Please sign in to comment.