new design with nice layout
This commit is contained in:
@@ -1,18 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
class CreateAdmin extends Command {
|
||||
protected $signature='absdev:create-admin {email}';
|
||||
protected $description='Create or promote an administrator (password entered securely)';
|
||||
public function handle(): int {
|
||||
$email=$this->argument('email');
|
||||
if (!filter_var($email,FILTER_VALIDATE_EMAIL)) { $this->error('Invalid email address.'); return self::FAILURE; }
|
||||
$password=$this->secret('Password (minimum 12 characters)');
|
||||
if (!is_string($password) || strlen($password)<12) { $this->error('Password must be at least 12 characters.'); return self::FAILURE; }
|
||||
$user=User::firstOrNew(['email'=>$email]);
|
||||
if (!$user->exists) $user->name=$this->ask('Administrator name','Administrator');
|
||||
$user->password=$password; $user->is_admin=true; $user->save();
|
||||
$this->info('Administrator account ready.'); return self::SUCCESS;
|
||||
|
||||
class CreateAdmin extends Command
|
||||
{
|
||||
protected $signature = 'absdev:create-admin {email}';
|
||||
|
||||
protected $description = 'Create or promote an administrator (password entered securely)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$email = $this->argument('email');
|
||||
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$this->error('Invalid email address.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
$password = $this->secret('Password (minimum 12 characters)');
|
||||
if (! is_string($password) || strlen($password) < 12) {
|
||||
$this->error('Password must be at least 12 characters.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
$user = User::firstOrNew(['email' => $email]);
|
||||
if (! $user->exists) {
|
||||
$user->name = $this->ask('Administrator name', 'Administrator');
|
||||
}
|
||||
$user->password = $password;
|
||||
$user->is_admin = true;
|
||||
$user->save();
|
||||
$this->info('Administrator account ready.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
class LoginController extends Controller {
|
||||
public function show() { return view('auth.login'); }
|
||||
public function login(Request $request) {
|
||||
$credentials=$request->validate(['email'=>'required|email','password'=>'required|string']);
|
||||
if (!Auth::attempt([...$credentials,'is_admin'=>true],$request->boolean('remember'))) {
|
||||
throw ValidationException::withMessages(['email'=>'Invalid administrator credentials.']);
|
||||
}
|
||||
$request->session()->regenerate(); return redirect()->intended(route('admin.dashboard'));
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function show()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
public function logout(Request $request) {
|
||||
Auth::logout(); $request->session()->invalidate(); $request->session()->regenerateToken();
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->validate(['email' => 'required|email', 'password' => 'required|string']);
|
||||
if (! Auth::attempt([...$credentials, 'is_admin' => true], $request->boolean('remember'))) {
|
||||
throw ValidationException::withMessages(['email' => 'Invalid administrator credentials.']);
|
||||
}
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(route('admin.dashboard'));
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
class EnsureAdmin {
|
||||
public function handle(Request $request, Closure $next): Response {
|
||||
abort_unless($request->user()?->is_admin,403);
|
||||
|
||||
class EnsureAdmin
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
abort_unless($request->user()?->is_admin, 403);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\ContactEnquiry;
|
||||
use App\Models\SiteSection;
|
||||
use App\Models\SiteSetting;
|
||||
use Livewire\Component;
|
||||
class Dashboard extends Component {
|
||||
public function render() {
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.dashboard', [
|
||||
'totalEnquiries'=>ContactEnquiry::count(), 'unreadEnquiries'=>ContactEnquiry::where('is_read',false)->count(),
|
||||
'sectionCount'=>SiteSection::count(), 'publishedSections'=>SiteSection::where('is_visible',true)->count(),
|
||||
'recentEnquiries'=>ContactEnquiry::latest()->limit(5)->get(),
|
||||
])->layout('layouts.admin', ['title'=>'Overview']);
|
||||
'totalEnquiries' => ContactEnquiry::count(), 'unreadEnquiries' => ContactEnquiry::where('is_read', false)->count(),
|
||||
'sectionCount' => SiteSection::count(), 'publishedSections' => SiteSection::where('is_visible', true)->count(),
|
||||
'recentEnquiries' => ContactEnquiry::latest()->limit(5)->get(),
|
||||
])->layout('layouts.admin', ['title' => 'Overview']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\ContactEnquiry;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
class Enquiries extends Component {
|
||||
|
||||
class Enquiries extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
public string $filter='all';
|
||||
public function updatingFilter(): void { $this->resetPage(); }
|
||||
public function markRead(int $id): void { ContactEnquiry::findOrFail($id)->update(['is_read'=>true]); }
|
||||
public function delete(int $id): void { ContactEnquiry::findOrFail($id)->delete(); }
|
||||
public function render() {
|
||||
$query=ContactEnquiry::latest();
|
||||
if ($this->filter==='unread') $query->where('is_read',false);
|
||||
return view('livewire.admin.enquiries',['enquiries'=>$query->paginate(12)])->layout('layouts.admin',['title'=>'Enquiries']);
|
||||
|
||||
public string $filter = 'all';
|
||||
|
||||
public function updatingFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function markRead(int $id): void
|
||||
{
|
||||
ContactEnquiry::findOrFail($id)->update(['is_read' => true]);
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
ContactEnquiry::findOrFail($id)->delete();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$query = ContactEnquiry::latest();
|
||||
if ($this->filter === 'unread') {
|
||||
$query->where('is_read', false);
|
||||
}
|
||||
|
||||
return view('livewire.admin.enquiries', ['enquiries' => $query->paginate(12)])->layout('layouts.admin', ['title' => 'Enquiries']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\SiteSection;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Component;
|
||||
class Sections extends Component {
|
||||
|
||||
class Sections extends Component
|
||||
{
|
||||
public ?int $editingId = null;
|
||||
|
||||
public string $key = '';
|
||||
|
||||
public string $eyebrow = '';
|
||||
|
||||
public string $title = '';
|
||||
|
||||
public string $body = '';
|
||||
|
||||
public string $button_label = '';
|
||||
|
||||
public string $button_url = '';
|
||||
|
||||
public bool $is_visible = true;
|
||||
|
||||
public int $sort_order = 0;
|
||||
public function edit(int $id): void {
|
||||
$s=SiteSection::findOrFail($id);
|
||||
$this->editingId=$s->id;
|
||||
foreach (['key','eyebrow','title','body','button_label','button_url','is_visible','sort_order'] as $field) $this->$field=$s->$field ?? (is_bool($this->$field) ? false : '');
|
||||
|
||||
public function edit(int $id): void
|
||||
{
|
||||
$s = SiteSection::findOrFail($id);
|
||||
$this->editingId = $s->id;
|
||||
foreach (['key', 'eyebrow', 'title', 'body', 'button_label', 'button_url', 'is_visible', 'sort_order'] as $field) {
|
||||
$this->$field = $s->$field ?? (is_bool($this->$field) ? false : '');
|
||||
}
|
||||
}
|
||||
public function add(): void { $this->reset(['editingId','key','eyebrow','title','body','button_label','button_url','sort_order']); $this->is_visible=true; }
|
||||
public function save(): void {
|
||||
$data=$this->validate([
|
||||
'key'=>['required','alpha_dash','max:80', Rule::unique('site_sections','key')->ignore($this->editingId)],
|
||||
'eyebrow'=>'nullable|string|max:255','title'=>'required|string|max:255','body'=>'nullable|string|max:5000',
|
||||
'button_label'=>'nullable|string|max:100','button_url'=>'nullable|string|max:500',
|
||||
'is_visible'=>'boolean','sort_order'=>'integer|min:0|max:999',
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
$this->reset(['editingId', 'key', 'eyebrow', 'title', 'body', 'button_label', 'button_url', 'sort_order']);
|
||||
$this->is_visible = true;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->validate([
|
||||
'key' => ['required', 'alpha_dash', 'max:80', Rule::unique('site_sections', 'key')->ignore($this->editingId)],
|
||||
'eyebrow' => 'nullable|string|max:255', 'title' => 'required|string|max:255', 'body' => 'nullable|string|max:5000',
|
||||
'button_label' => 'nullable|string|max:100', 'button_url' => 'nullable|string|max:500',
|
||||
'is_visible' => 'boolean', 'sort_order' => 'integer|min:0|max:999',
|
||||
]);
|
||||
SiteSection::updateOrCreate(['id'=>$this->editingId], $data);
|
||||
$this->add(); session()->flash('status','Section saved successfully.');
|
||||
SiteSection::updateOrCreate(['id' => $this->editingId], $data);
|
||||
$this->add();
|
||||
session()->flash('status', 'Section saved successfully.');
|
||||
}
|
||||
|
||||
public function toggle(int $id): void
|
||||
{
|
||||
$s = SiteSection::findOrFail($id);
|
||||
$s->update(['is_visible' => ! $s->is_visible]);
|
||||
}
|
||||
|
||||
public function delete(int $id): void
|
||||
{
|
||||
SiteSection::findOrFail($id)->delete();
|
||||
if ($this->editingId === $id) {
|
||||
$this->add();
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.sections', ['sections' => SiteSection::orderBy('sort_order')->get()])->layout('layouts.admin', ['title' => 'Page sections']);
|
||||
}
|
||||
public function toggle(int $id): void { $s=SiteSection::findOrFail($id); $s->update(['is_visible'=>!$s->is_visible]); }
|
||||
public function delete(int $id): void { SiteSection::findOrFail($id)->delete(); if ($this->editingId===$id) $this->add(); }
|
||||
public function render() { return view('livewire.admin.sections',['sections'=>SiteSection::orderBy('sort_order')->get()])->layout('layouts.admin',['title'=>'Page sections']); }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Admin;
|
||||
|
||||
use App\Models\SiteSetting;
|
||||
use Livewire\Component;
|
||||
class Settings extends Component {
|
||||
public string $site_name=''; public string $email=''; public string $footer_tagline=''; public string $location='';
|
||||
public function mount(): void { foreach (['site_name','email','footer_tagline','location'] as $key) $this->$key=SiteSetting::where('key',$key)->value('value') ?? ''; }
|
||||
public function save(): void {
|
||||
$data=$this->validate(['site_name'=>'required|string|max:100','email'=>'required|email|max:255',
|
||||
'footer_tagline'=>'nullable|string|max:255','location'=>'nullable|string|max:255']);
|
||||
foreach ($data as $key=>$value) SiteSetting::updateOrCreate(['key'=>$key],['value'=>$value]);
|
||||
session()->flash('status','Settings updated.');
|
||||
|
||||
class Settings extends Component
|
||||
{
|
||||
public string $site_name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
public string $footer_tagline = '';
|
||||
|
||||
public string $location = '';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
foreach (['site_name', 'email', 'footer_tagline', 'location'] as $key) {
|
||||
$this->$key = SiteSetting::where('key', $key)->value('value') ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->validate(['site_name' => 'required|string|max:100', 'email' => 'required|email|max:255',
|
||||
'footer_tagline' => 'nullable|string|max:255', 'location' => 'nullable|string|max:255']);
|
||||
foreach ($data as $key => $value) {
|
||||
SiteSetting::updateOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
session()->flash('status', 'Settings updated.');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.admin.settings')->layout('layouts.admin', ['title' => 'Site settings']);
|
||||
}
|
||||
public function render() { return view('livewire.admin.settings')->layout('layouts.admin',['title'=>'Site settings']); }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\ContactEnquiry;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -8,21 +10,30 @@ use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
use function Illuminate\Support\defer;
|
||||
class ContactForm extends Component {
|
||||
|
||||
class ContactForm extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public string $email = '';
|
||||
|
||||
public string $company = '';
|
||||
|
||||
public string $service = '';
|
||||
|
||||
public string $message = '';
|
||||
|
||||
public string $website = '';
|
||||
|
||||
public bool $submitted = false;
|
||||
|
||||
/** Save a valid enquiry before attempting its email notification. */
|
||||
public function submit(): void
|
||||
{
|
||||
$this->validate(['name'=>'required|string|max:120','email'=>'required|email|max:255','company'=>'nullable|string|max:120',
|
||||
'service'=>'nullable|string|max:100','message'=>'required|string|min:10|max:5000','website'=>'nullable|max:0']);
|
||||
$enquiry = ContactEnquiry::create($this->only(['name','email','company','service','message']));
|
||||
$this->reset(['name','email','company','service','message']);
|
||||
$this->validate(['name' => 'required|string|max:120', 'email' => 'required|email|max:255', 'company' => 'nullable|string|max:120',
|
||||
'service' => 'nullable|string|max:100', 'message' => 'required|string|min:10|max:5000', 'website' => 'nullable|max:0']);
|
||||
$enquiry = ContactEnquiry::create($this->only(['name', 'email', 'company', 'service', 'message']));
|
||||
$this->reset(['name', 'email', 'company', 'service', 'message']);
|
||||
$this->submitted = true;
|
||||
|
||||
defer(fn () => $this->notifyByEmail($enquiry))->always();
|
||||
@@ -69,5 +80,8 @@ class ContactForm extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
public function render() { return view('livewire.contact-form'); }
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.contact-form');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class ContactEnquiry extends Model {
|
||||
protected $fillable = ['name','email','company','service','message','is_read'];
|
||||
protected function casts(): array { return ['is_read'=>'boolean']; }
|
||||
|
||||
class ContactEnquiry extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'email', 'company', 'service', 'message', 'is_read'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['is_read' => 'boolean'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class SiteSection extends Model {
|
||||
protected $fillable = ['key','eyebrow','title','body','button_label','button_url','is_visible','sort_order'];
|
||||
protected function casts(): array { return ['is_visible'=>'boolean','sort_order'=>'integer']; }
|
||||
|
||||
class SiteSection extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'eyebrow', 'title', 'body', 'button_label', 'button_url', 'is_visible', 'sort_order'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['is_visible' => 'boolean', 'sort_order' => 'integer'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
class SiteSetting extends Model { protected $fillable = ['key','value']; }
|
||||
|
||||
class SiteSetting extends Model
|
||||
{
|
||||
protected $fillable = ['key', 'value'];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"predis/predis": "^3.7"
|
||||
},
|
||||
"require-dev": {
|
||||
"deployer/deployer": "^8.0",
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.5",
|
||||
"laravel/pao": "^1.0.6",
|
||||
|
||||
@@ -4,26 +4,46 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', fn (Blueprint $table) => $table->boolean('is_admin')->default(false));
|
||||
Schema::create('site_sections', function (Blueprint $table) {
|
||||
$table->id(); $table->string('key')->unique(); $table->string('eyebrow')->nullable();
|
||||
$table->string('title'); $table->text('body')->nullable(); $table->string('button_label')->nullable();
|
||||
$table->string('button_url')->nullable(); $table->boolean('is_visible')->default(true);
|
||||
$table->unsignedInteger('sort_order')->default(0); $table->timestamps();
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->string('eyebrow')->nullable();
|
||||
$table->string('title');
|
||||
$table->text('body')->nullable();
|
||||
$table->string('button_label')->nullable();
|
||||
$table->string('button_url')->nullable();
|
||||
$table->boolean('is_visible')->default(true);
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('site_settings', function (Blueprint $table) {
|
||||
$table->id(); $table->string('key')->unique(); $table->text('value')->nullable(); $table->timestamps();
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('contact_enquiries', function (Blueprint $table) {
|
||||
$table->id(); $table->string('name'); $table->string('email'); $table->string('company')->nullable();
|
||||
$table->string('service')->nullable(); $table->text('message'); $table->boolean('is_read')->default(false);
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('company')->nullable();
|
||||
$table->string('service')->nullable();
|
||||
$table->text('message');
|
||||
$table->boolean('is_read')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('contact_enquiries'); Schema::dropIfExists('site_settings');
|
||||
Schema::dropIfExists('site_sections'); Schema::table('users', fn (Blueprint $table) => $table->dropColumn('is_admin'));
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contact_enquiries');
|
||||
Schema::dropIfExists('site_settings');
|
||||
Schema::dropIfExists('site_sections');
|
||||
Schema::table('users', fn (Blueprint $table) => $table->dropColumn('is_admin'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
class DatabaseSeeder extends Seeder { public function run(): void { $this->call(SiteContentSeeder::class); } }
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(SiteContentSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\SiteSection;
|
||||
use App\Models\SiteSetting;
|
||||
use Illuminate\Database\Seeder;
|
||||
class SiteContentSeeder extends Seeder {
|
||||
public function run(): void {
|
||||
|
||||
class SiteContentSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$sections = [
|
||||
['hero','Independent by design. Exceptional by default.','Digital experiences built to move your business forward.','We craft considered software, polished websites, and practical digital products for ambitious businesses. From the first sketch to the final deployment, every detail matters.','Start a project','#contact'],
|
||||
['services','WHAT WE DO','Technology with a human touch.','Strategy, design and engineering working together. Modern tools, clear thinking and software that genuinely earns its place.','Explore our services','#services'],
|
||||
['approach','HOW WE WORK','Small team energy. Big picture thinking.','Direct collaboration, honest communication and a relentless focus on outcomes. We keep projects agile, transparent and built for the long term.','Our process','#process'],
|
||||
['work','SELECTED EXPERTISE','From complex challenges to elegant solutions.','We turn real-world problems into streamlined systems, thoughtful products and reliable digital infrastructure.','Talk about your idea','#contact'],
|
||||
['cta','LET’S BUILD SOMETHING','Your next chapter starts with a conversation.','Tell us what you are building. We will help map out the smartest way forward.','Get in touch','#contact'],
|
||||
['hero', 'Independent by design. Exceptional by default.', 'Digital experiences built to move your business forward.', 'We craft considered software, polished websites, and practical digital products for ambitious businesses. From the first sketch to the final deployment, every detail matters.', 'Start a project', '#contact'],
|
||||
['services', 'WHAT WE DO', 'Technology with a human touch.', 'Strategy, design and engineering working together. Modern tools, clear thinking and software that genuinely earns its place.', 'Explore our services', '#services'],
|
||||
['approach', 'HOW WE WORK', 'Small team energy. Big picture thinking.', 'Direct collaboration, honest communication and a relentless focus on outcomes. We keep projects agile, transparent and built for the long term.', 'Our process', '#process'],
|
||||
['work', 'SELECTED EXPERTISE', 'From complex challenges to elegant solutions.', 'We turn real-world problems into streamlined systems, thoughtful products and reliable digital infrastructure.', 'Talk about your idea', '#contact'],
|
||||
['cta', 'LET’S BUILD SOMETHING', 'Your next chapter starts with a conversation.', 'Tell us what you are building. We will help map out the smartest way forward.', 'Get in touch', '#contact'],
|
||||
];
|
||||
foreach ($sections as $i => [$key,$eyebrow,$title,$body,$button,$url]) {
|
||||
SiteSection::firstOrCreate(['key'=>$key], ['eyebrow'=>$eyebrow,'title'=>$title,'body'=>$body,'button_label'=>$button,'button_url'=>$url,'sort_order'=>$i]);
|
||||
SiteSection::firstOrCreate(['key' => $key], ['eyebrow' => $eyebrow, 'title' => $title, 'body' => $body, 'button_label' => $button, 'button_url' => $url, 'sort_order' => $i]);
|
||||
}
|
||||
foreach (['site_name'=>'ABSDEV','email'=>'[email protected]','footer_tagline'=>'Independent software. Thoughtfully engineered.','location'=>'United Kingdom'] as $key=>$value) {
|
||||
SiteSetting::firstOrCreate(['key'=>$key], ['value'=>$value]);
|
||||
foreach (['site_name' => 'ABSDEV', 'email' => '[email protected]', 'footer_tagline' => 'Independent software. Thoughtfully engineered.', 'location' => 'United Kingdom'] as $key => $value) {
|
||||
SiteSetting::firstOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-10
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Middleware\EnsureAdmin;
|
||||
use App\Livewire\Admin\Dashboard;
|
||||
@@ -11,8 +12,8 @@ use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome', [
|
||||
'sections'=>SiteSection::where('is_visible',true)->orderBy('sort_order')->get()->keyBy('key'),
|
||||
'settings'=>SiteSetting::pluck('value','key'),
|
||||
'sections' => SiteSection::where('is_visible', true)->orderBy('sort_order')->get()->keyBy('key'),
|
||||
'settings' => SiteSetting::pluck('value', 'key'),
|
||||
]);
|
||||
})->name('home');
|
||||
// Dedicated public service, expertise and process pages.
|
||||
@@ -27,13 +28,13 @@ foreach (['services', 'expertise', 'approach'] as $slug) {
|
||||
})->name($slug);
|
||||
}
|
||||
Route::middleware('guest')->group(function () {
|
||||
Route::get('/admin/login',[LoginController::class,'show'])->name('login');
|
||||
Route::post('/admin/login',[LoginController::class,'login'])->middleware('throttle:5,1')->name('login.submit');
|
||||
Route::get('/admin/login', [LoginController::class, 'show'])->name('login');
|
||||
Route::post('/admin/login', [LoginController::class, 'login'])->middleware('throttle:5,1')->name('login.submit');
|
||||
});
|
||||
Route::post('/admin/logout',[LoginController::class,'logout'])->middleware('auth')->name('logout');
|
||||
Route::prefix('admin')->name('admin.')->middleware(['auth',EnsureAdmin::class])->group(function () {
|
||||
Route::get('/',Dashboard::class)->name('dashboard');
|
||||
Route::get('/sections',Sections::class)->name('sections');
|
||||
Route::get('/enquiries',Enquiries::class)->name('enquiries');
|
||||
Route::get('/settings',Settings::class)->name('settings');
|
||||
Route::post('/admin/logout', [LoginController::class, 'logout'])->middleware('auth')->name('logout');
|
||||
Route::prefix('admin')->name('admin.')->middleware(['auth', EnsureAdmin::class])->group(function () {
|
||||
Route::get('/', Dashboard::class)->name('dashboard');
|
||||
Route::get('/sections', Sections::class)->name('sections');
|
||||
Route::get('/enquiries', Enquiries::class)->name('enquiries');
|
||||
Route::get('/settings', Settings::class)->name('settings');
|
||||
});
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\SiteSection;
|
||||
use Database\Seeders\SiteContentSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
class AbsdevBrandAndHomeTest extends TestCase {
|
||||
|
||||
class AbsdevBrandAndHomeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
public function test_homepage_has_a_complete_hero_without_seed_data(): void {
|
||||
|
||||
public function test_homepage_has_a_complete_hero_without_seed_data(): void
|
||||
{
|
||||
$this->get('/')->assertOk()->assertSee('Ideas')->assertSee('Technology with a human touch.');
|
||||
}
|
||||
public function test_homepage_links_to_the_new_pages_and_favicon(): void {
|
||||
|
||||
public function test_homepage_links_to_the_new_pages_and_favicon(): void
|
||||
{
|
||||
$this->get('/')->assertOk()->assertSee('/favicon.svg')->assertSee('href="'.route('services').'"', false)
|
||||
->assertSee('href="'.route('expertise').'"', false)->assertSee('href="'.route('approach').'"', false);
|
||||
}
|
||||
public function test_hidden_cms_section_stays_hidden(): void {
|
||||
$this->seed(\Database\Seeders\SiteContentSeeder::class);
|
||||
\App\Models\SiteSection::where('key','hero')->update(['is_visible'=>false]);
|
||||
$this->get('/')->assertOk()->assertDontSee('Ideas<span',false);
|
||||
|
||||
public function test_hidden_cms_section_stays_hidden(): void
|
||||
{
|
||||
$this->seed(SiteContentSeeder::class);
|
||||
SiteSection::where('key', 'hero')->update(['is_visible' => false]);
|
||||
$this->get('/')->assertOk()->assertDontSee('Ideas<span', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
use App\Livewire\ContactForm;
|
||||
|
||||
use App\Livewire\Admin\Sections;
|
||||
use App\Livewire\ContactForm;
|
||||
use App\Models\ContactEnquiry;
|
||||
use App\Models\SiteSection;
|
||||
use App\Models\User;
|
||||
@@ -9,43 +11,64 @@ use Database\Seeders\SiteContentSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
class SiteExperienceTest extends TestCase {
|
||||
|
||||
class SiteExperienceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
public function test_homepage_displays_published_content(): void {
|
||||
|
||||
public function test_homepage_displays_published_content(): void
|
||||
{
|
||||
$this->seed(SiteContentSeeder::class);
|
||||
$this->get('/')->assertOk()->assertSee('Digital experiences built to move your business forward.');
|
||||
SiteSection::where('key','hero')->update(['is_visible'=>false]);
|
||||
SiteSection::where('key', 'hero')->update(['is_visible' => false]);
|
||||
$this->get('/')->assertOk()->assertDontSee('Digital experiences built to move your business forward.');
|
||||
}
|
||||
public function test_contact_form_validates_and_saves_enquiry(): void {
|
||||
Livewire::test(ContactForm::class)->set('name','Test Client')->set('email','[email protected]')
|
||||
->set('message','Please build a Laravel website for my business.')->call('submit')->assertHasNoErrors();
|
||||
$this->assertDatabaseHas('contact_enquiries',['email'=>'[email protected]','is_read'=>false]);
|
||||
|
||||
public function test_contact_form_validates_and_saves_enquiry(): void
|
||||
{
|
||||
Livewire::test(ContactForm::class)->set('name', 'Test Client')->set('email', '[email protected]')
|
||||
->set('message', 'Please build a Laravel website for my business.')->call('submit')->assertHasNoErrors();
|
||||
$this->assertDatabaseHas('contact_enquiries', ['email' => '[email protected]', 'is_read' => false]);
|
||||
}
|
||||
public function test_guests_cannot_open_admin_dashboard(): void { $this->get('/admin')->assertRedirect(route('login')); }
|
||||
public function test_non_admin_cannot_access_admin_pages(): void {
|
||||
|
||||
public function test_guests_cannot_open_admin_dashboard(): void
|
||||
{
|
||||
$this->get('/admin')->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
public function test_non_admin_cannot_access_admin_pages(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create())->get('/admin')->assertForbidden();
|
||||
}
|
||||
public function test_admin_can_edit_site_content(): void {
|
||||
$admin=User::factory()->create(['is_admin'=>true]); $this->actingAs($admin);
|
||||
Livewire::test(Sections::class)->set('key','hero')->set('title','A better digital future')
|
||||
->set('body','Custom messaging')->set('is_visible',true)->call('save')->assertHasNoErrors();
|
||||
$this->assertDatabaseHas('site_sections',['key'=>'hero','title'=>'A better digital future']);
|
||||
|
||||
public function test_admin_can_edit_site_content(): void
|
||||
{
|
||||
$admin = User::factory()->create(['is_admin' => true]);
|
||||
$this->actingAs($admin);
|
||||
Livewire::test(Sections::class)->set('key', 'hero')->set('title', 'A better digital future')
|
||||
->set('body', 'Custom messaging')->set('is_visible', true)->call('save')->assertHasNoErrors();
|
||||
$this->assertDatabaseHas('site_sections', ['key' => 'hero', 'title' => 'A better digital future']);
|
||||
}
|
||||
public function test_dedicated_public_pages_render_with_navigation_and_content(): void {
|
||||
|
||||
public function test_dedicated_public_pages_render_with_navigation_and_content(): void
|
||||
{
|
||||
foreach (['services' => 'Digital services', 'expertise' => 'Deep engineering', 'approach' => 'A clear process'] as $url => $heading) {
|
||||
$this->get('/'.$url)->assertOk()->assertSee($heading)->assertSee('Capability with purpose');
|
||||
}
|
||||
}
|
||||
public function test_homepage_navigation_links_to_dedicated_pages(): void {
|
||||
|
||||
public function test_homepage_navigation_links_to_dedicated_pages(): void
|
||||
{
|
||||
$this->seed(SiteContentSeeder::class);
|
||||
$this->get('/')->assertOk()->assertSee('href="'.route('services').'"', false)
|
||||
->assertSee('href="'.route('expertise').'"', false)
|
||||
->assertSee('href="'.route('approach').'"', false);
|
||||
}
|
||||
public function test_honeypot_rejects_spam(): void {
|
||||
Livewire::test(ContactForm::class)->set('name','Spam')->set('email','[email protected]')
|
||||
->set('message','Spam message example')->set('website','spambot')->call('submit')->assertHasErrors(['website']);
|
||||
$this->assertSame(0,ContactEnquiry::count());
|
||||
|
||||
public function test_honeypot_rejects_spam(): void
|
||||
{
|
||||
Livewire::test(ContactForm::class)->set('name', 'Spam')->set('email', '[email protected]')
|
||||
->set('message', 'Spam message example')->set('website', 'spambot')->call('submit')->assertHasErrors(['website']);
|
||||
$this->assertSame(0, ContactEnquiry::count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user