- Implemented the customer portal workflow progress component with detailed service progress tracking, including current status, workflow steps, and contact information. - Developed a management workflow analytics dashboard featuring key performance indicators, charts for revenue by branch, labor utilization, and recent quality issues. - Created tests for admin-only middleware to ensure proper access control for admin routes. - Added tests for customer portal view rendering and workflow integration, ensuring the workflow service operates correctly through various stages. - Introduced a .gitignore file for the debugbar storage directory to prevent unnecessary files from being tracked.
86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Branches;
|
|
|
|
use Livewire\Component;
|
|
use App\Models\Branch;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
class Create extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public $code = '';
|
|
public $name = '';
|
|
public $address = '';
|
|
public $phone = '';
|
|
public $email = '';
|
|
public $manager_name = '';
|
|
public $city = '';
|
|
public $state = '';
|
|
public $postal_code = '';
|
|
public $is_active = true;
|
|
|
|
protected function rules()
|
|
{
|
|
return [
|
|
'code' => 'required|string|max:10|unique:branches,code',
|
|
'name' => 'required|string|max:255',
|
|
'address' => 'nullable|string|max:500',
|
|
'phone' => 'nullable|string|max:20',
|
|
'email' => 'nullable|email|max:255',
|
|
'manager_name' => 'nullable|string|max:255',
|
|
'city' => 'nullable|string|max:100',
|
|
'state' => 'nullable|string|max:50',
|
|
'postal_code' => 'nullable|string|max:10',
|
|
'is_active' => 'boolean',
|
|
];
|
|
}
|
|
|
|
protected $messages = [
|
|
'code.required' => 'Branch code is required.',
|
|
'code.unique' => 'This branch code is already taken.',
|
|
'name.required' => 'Branch name is required.',
|
|
'email.email' => 'Please enter a valid email address.',
|
|
];
|
|
|
|
public function mount()
|
|
{
|
|
$this->authorize('create', Branch::class);
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$this->authorize('create', Branch::class);
|
|
|
|
$this->validate();
|
|
|
|
try {
|
|
Branch::create([
|
|
'code' => strtoupper($this->code),
|
|
'name' => $this->name,
|
|
'address' => $this->address,
|
|
'phone' => $this->phone,
|
|
'email' => $this->email,
|
|
'manager_name' => $this->manager_name,
|
|
'city' => $this->city,
|
|
'state' => $this->state,
|
|
'postal_code' => $this->postal_code,
|
|
'is_active' => $this->is_active,
|
|
]);
|
|
|
|
session()->flash('success', 'Branch created successfully.');
|
|
|
|
return redirect()->route('branches.index');
|
|
|
|
} catch (\Exception $e) {
|
|
session()->flash('error', 'Failed to create branch: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.branches.create');
|
|
}
|
|
}
|