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

Feat : cms header #86

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ jobs:
unzip -o app.zip -d /home/${{ secrets.SSH_USERNAME }}/public_html/
rm -rf app.zip
sed -i~ '/^VERSION=/s/=.*/="${{ vars.VERSION }}"/' .env
php artisan migrate --force
# sed -i~ '/^HASH_VERSION=/s/=.*/="${{ github.sha }}"/' .env
# sed -i~ '/^HASH_VERSION=/s/=.*/="${{ vars.HASH_VERSION }}"/' .env
92 changes: 92 additions & 0 deletions app/Filament/Resources/HeaderResource.php
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 app/Filament/Resources/HeaderResource/Pages/ManageHeaders.php
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(),
];
}
}
13 changes: 13 additions & 0 deletions app/Models/Header.php
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 = [];
}
6 changes: 5 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Providers;

// use Illuminate\Support\Facades\Vite;
use App\Models\Header;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -21,5 +21,9 @@ public function register(): void
public function boot(): void
{
// Vite::macro('image', fn (string $asset) => $this->asset("resources/images/{$asset}"));
view()->share(
'headers',
Header::orderBy('rank')->get() ?? []
);
}
}
31 changes: 31 additions & 0 deletions database/migrations/2024_07_09_181621_create_headers_table.php
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');
}
};
51 changes: 51 additions & 0 deletions database/seeders/HeaderSeeder.php
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
]);
}
}
}
1 change: 0 additions & 1 deletion resources/css/alert.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ section {
color: #fff;
font-size: 24px;
}

1 change: 1 addition & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@tailwind utilities;

@layer base {

html,
body {
font-family: "Poppins", sans-serif;
Expand Down
65 changes: 42 additions & 23 deletions resources/css/columner.css
Original file line number Diff line number Diff line change
@@ -1,44 +1,63 @@
.row
{
.row {
display: flex;
flex-wrap: wrap;
}

.col-2 { width: 16.666666667%; }
.col-3 { width: 25%; }
.col-4 { width: 33.33%; }
.col-5 { width: 41.666666667%; }
.col-6 { width: 50%; }
.col-7 { width: 58.33%; }
.col-8 { width: 66.666666667%; }
.col-9 { width: 75%; }
.col-12 { width: 100%; }
.col-2 {
width: 16.666666667%;
}

.col-3 {
width: 25%;
}

.col-4 {
width: 33.33%;
}

.col-5 {
width: 41.666666667%;
}

.col-6 {
width: 50%;
}

.col-7 {
width: 58.33%;
}

.col-8 {
width: 66.666666667%;
}

.col-9 {
width: 75%;
}

.col-12 {
width: 100%;
}

[class*="col-"]
{
[class*="col-"] {
padding-left: 20px;
padding-right: 20px;
}

[class*="col-"]:first-child
{
[class*="col-"]:first-child {
padding-left: 0px;
}

[class*="col-"]:last-child
{
[class*="col-"]:last-child {
padding-right: 0px;
}

.row.no-padding>[class*="col-"]
{
.row.no-padding>[class*="col-"] {
padding: 0px;
}

@media only screen and (max-width: 900px)
{
[class*="col-"]
{
@media only screen and (max-width: 900px) {
[class*="col-"] {
width: 100%;
padding: 0px;
}
Expand Down
Loading