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

Site settings refectoring #261

Merged
merged 6 commits into from
Sep 2, 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
53 changes: 6 additions & 47 deletions app/Filament/Admin/Resources/GlobalSettingsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
namespace App\Filament\Admin\Resources;

use App\Filament\Admin\Resources\GlobalSettingsResource\Pages;
use App\Filament\Admin\Resources\GlobalSettingsResource\RelationManagers;
use App\Models\GlobalSettings;
use App\Models\SiteSettings;
use Faker\Provider\ar_EG\Text;
use Filament\Forms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Forms;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Intelrx\Sitesettings\Models\SiteSettings;

class GlobalSettingsResource extends Resource
{
Expand All @@ -27,53 +20,19 @@ class GlobalSettingsResource extends Resource

public static function form(Form $form): Form
{
// $table->string('name')->nullable();
// $table->string('currency')->nullable();
// $table->string('default_language')->nullable();
// $table->text('address')->nullable();
// $table->string('country')->nullable();
// $table->string('email')->nullable();
// $table->string('phone_01')->nullable();
// $table->string('phone_02')->nullable();
// $table->string('phone_03')->nullable();
// $table->string('phone_04')->nullable();
// $table->string('facebook')->nullable();
// $table->string('twitter')->nullable();
// $table->string('github')->nullable();
// $table->string('youtube')->nullable();
// $table->decimal('sales_commission_percentage', 5, 2)->default(1.00);
// $table->decimal('lettings_commission_percentage', 5, 2)->default(8.00);
return $form
->schema([
TextInput::make('name')->autocapitalize('words')->required(),
TextInput::make('currency')->autocapitalize('words')->required(),
TextInput::make('default_language')->autocapitalize('words')->required(),
TextInput::make('address')->autocapitalize('words')->required(),
TextInput::make('country')->autocapitalize('words')->required(),
TextInput::make('email')->autocapitalize('words')->required(),
TextInput::make('phone_01')->autocapitalize('words')->required(),
TextInput::make('phone_02')->autocapitalize('words'),
TextInput::make('phone_03')->autocapitalize('words'),
TextInput::make('phone_04')->autocapitalize('words'),
TextInput::make('facebook')->autocapitalize('words')->required(),
TextInput::make('twitter')->autocapitalize('words')->required(),
TextInput::make('github')->autocapitalize('words')->required(),
TextInput::make('youtube')->autocapitalize('words')->required(),
TextInput::make('sales_commission_percentage')->autocapitalize('words')->required(),
TextInput::make('lettings_commission_percentage')->autocapitalize('words')->required(),
Forms\Components\TextInput::make('key')->label('Title')->required(),
Forms\Components\TextInput::make('value')->required(),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('currency'),
TextColumn::make('default_language')->label('language'),
TextColumn::make('country'),
TextColumn::make('email'),
TextColumn::make('phone_01')->label('Phone'),
Tables\Columns\TextColumn::make('key')->label('Title'),
Tables\Columns\TextColumn::make('value')->label('Value'),
])
->filters([
//
Expand Down
13 changes: 0 additions & 13 deletions app/Helpers/SiteSettingsHelper.php

This file was deleted.

14 changes: 0 additions & 14 deletions app/Models/SiteSettings.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Services/SiteSettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Services;

use App\Models\SiteSettings;
use Intelrx\Sitesettings\Models\SiteSettings;
use Illuminate\Support\Facades\Cache;

class SiteSettingsService
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"php": "^8.2",
"bezhansalleh/filament-shield": "^3.2",
"guzzlehttp/guzzle": "^7.8",
"intelrx/sitesettings": "^1.0",
"joelbutcher/socialstream": "*",
"laravel/framework": "^11.0",
"laravel/jetstream": "*",
Expand Down
49 changes: 48 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
App\Providers\Filament\AdminPanelProvider::class,
App\Providers\Filament\AppPanelProvider::class,
App\Providers\RouteServiceProvider::class,

Intelrx\Sitesettings\SitesettingsProvider::class,
App\Providers\TeamServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
Expand All @@ -192,6 +192,8 @@
'aliases' => Facade::defaultAliases()->merge([
// 'Example' => App\Facades\Example::class,
'Menu' => Spatie\Menu\Laravel\Facades\Menu::class,
'SiteConfig' => Intelrx\Sitesettings\SiteConfig::class,

])->toArray(),

];

This file was deleted.

14 changes: 9 additions & 5 deletions database/seeders/SiteSettingsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\SiteSettings;
use Intelrx\Sitesettings\SiteConfig;

class SiteSettingsSeeder extends Seeder
{
public function run()
{
SiteSettings::create([
'name' => config('app.name', 'Liberu Real Estate'),
$data = [
'name' => config('app.name', 'Liberu '),
'currency' => '£',
'default_language' => 'en',
'address' => '123 Real Estate St, London, UK',
'address' => '123 St, London, UK',
'country' => 'United Kingdom',
'email' => 'info@liberurealestate.com',
'phone_01' => '+44 123 456 7890',
Expand All @@ -24,6 +24,10 @@ public function run()
'twitter' => 'https://twitter.com/liberusoftware',
'github' => 'https://Github.com/liberusoftware',
'youtube' => 'https://YouTube.com/@liberusoftware',
]);
];

foreach ($data as $key => $value) {
SiteConfig::store($key, $value);
}
}
}
8 changes: 4 additions & 4 deletions resources/views/livewire/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@
</div>

<div class="space-x-4">
<a href="{{ \App\Services\SiteSettingsService::get('facebook') }}"
<a href="{{ SiteConfig::get('facebook') }}"
class="inline-block text-gray-500 hover:text-gray-800 focus:outline-none focus:text-gray-800">
<svg class="shrink-0 size-4" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd"
d="M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.878v-6.987h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.988C18.343 21.128 22 16.991 22 12z"
clip-rule="evenodd" />
</svg>

<a href="{{ \App\Services\SiteSettingsService::get('twitter') }}"
<a href="{{ SiteConfig::get('twitter') }}"
class="inline-block text-gray-500 hover:text-gray-800 focus:outline-none focus:text-gray-800">
<svg class="shrink-0 size-4" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path
d="M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84" />
</svg>
</a>
<a href="{{ \App\Services\SiteSettingsService::get('github') }}"
<a href="{{ SiteConfig::get('github') }}"
class="inline-block text-gray-500 hover:text-gray-800 focus:outline-none focus:text-gray-800">
<svg class="shrink-0 size-4" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path fill-rule="evenodd"
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
clip-rule="evenodd" />
</svg>
</a>
<a href="{{ \App\Services\SiteSettingsService::get('youtube') }}"
<a href="{{ SiteConfig::get('youtube') }}"
class="inline-block text-gray-500 hover:text-gray-800 focus:outline-none focus:text-gray-800">
<svg class="shrink-0 size-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24"
height="24" fill="currentColor" viewBox="0 0 24 24">
Expand Down
Loading