-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add dynamic header cms * feat: add artisan migrate in cd
- Loading branch information
1 parent
17568b3
commit 7727b26
Showing
17 changed files
with
315 additions
and
142 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
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,92 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\HeaderResource\Pages; | ||
use App\Models\Header; | ||
use Filament\Forms\Components\Grid; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Components\Toggle; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Columns\ToggleColumn; | ||
use Filament\Tables\Table; | ||
|
||
class HeaderResource extends Resource | ||
{ | ||
protected static ?string $model = Header::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; | ||
|
||
protected static ?string $navigationGroup = 'CMS'; | ||
|
||
public static function getPluralLabel(): string | ||
{ | ||
return __('Header'); | ||
} | ||
|
||
public static function getModelLabel(): string | ||
{ | ||
return __('Header'); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Grid::make('') | ||
->columns(2) | ||
->schema([ | ||
TextInput::make('title') | ||
->label('Judul') | ||
->required(), | ||
TextInput::make('url') | ||
->label('URL') | ||
->prefix(route('home') . '/') | ||
->required(), | ||
TextInput::make('rank') | ||
->label('Rank') | ||
->integer() | ||
->required() | ||
]), | ||
Toggle::make('is_highlight') | ||
->label('Is Highlight') | ||
->required(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('title')->label('Judul'), | ||
TextColumn::make('url') | ||
->label('URL') | ||
->prefix(route('home') . '/'), | ||
TextColumn::make('rank')->label('Rank'), | ||
ToggleColumn::make('is_highlight')->label('Is Highlight') | ||
]) | ||
->defaultSort('rank', 'asc') | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ManageHeaders::route('/'), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/HeaderResource/Pages/ManageHeaders.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,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\HeaderResource\Pages; | ||
|
||
use App\Filament\Resources\HeaderResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ManageRecords; | ||
|
||
class ManageHeaders extends ManageRecords | ||
{ | ||
protected static string $resource = HeaderResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Header extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $guarded = []; | ||
} |
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
31 changes: 31 additions & 0 deletions
31
database/migrations/2024_07_09_181621_create_headers_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,31 @@ | ||
<?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('headers', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('title'); | ||
$table->string('url')->nullable(); | ||
$table->boolean('is_highlight')->default(false); | ||
$table->integer('rank')->default(1); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('headers'); | ||
} | ||
}; |
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,51 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use App\Models\Header; | ||
use Illuminate\Database\Console\Seeds\WithoutModelEvents; | ||
use Illuminate\Database\Seeder; | ||
|
||
class HeaderSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$headers = [ | ||
[ | ||
'DIES NATALIS Ke - 12 PERMIKOMNAS', | ||
'' | ||
], | ||
[ | ||
'PEKAN ESPORT Vol. 2', | ||
'pekanesport' | ||
], | ||
[ | ||
'PENGURUS', | ||
'structure' | ||
], | ||
[ | ||
'PROGRAM KERJA', | ||
'workplan' | ||
], | ||
[ | ||
'ARTIKEL', | ||
'article' | ||
], | ||
[ | ||
'DOKUMENTASI', | ||
'gallery' | ||
] | ||
]; | ||
|
||
foreach ($headers as $key => $value) { | ||
Header::create([ | ||
'title' => $value[0], | ||
'url' => $value[1], | ||
'rank' => $key | ||
]); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -98,4 +98,3 @@ section { | |
color: #fff; | ||
font-size: 24px; | ||
} | ||
|
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
@tailwind utilities; | ||
|
||
@layer base { | ||
|
||
html, | ||
body { | ||
font-family: "Poppins", sans-serif; | ||
|
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
Oops, something went wrong.