
Service-Oriented Architecture
Directory Structure
Modules/Units/{Domain}{Unit}/Filament/ subdirectoryClean Code Pattern
Type Safety
Type|null) where appropriateService suffixRepository suffixController suffix_class UserController
{
public string $user_name;
private string $_user_object;
protected string $_model_object;
}
_actclass UserController
{
public function showDetails(): void
private function _loadDetails(): array
protected function _deleteDetails(): bool
}
BaseService for common functionalityact prefix$this from action methods for method chainingpublic function actVerify(string $mobile, string $code): self
{
DB::beginTransaction();
try {
// Operation logic
DB::commit();
$this->setSuccessResponse(['data' => $result]);
} catch (\Exception $e) {
DB::rollBack();
$this->addError([], 'Error message');
}
return $this;
}
$this->_authService->actGetMobileNumber();
if ($this->_authService->hasErrors()) {
// Handle errors
} else {
$data = $this->_authService->getSuccessResponse()->getData();
// Continue processing
}
enum UserStatusEnum: int
{
/**
* User is active
*/
case ACTIVE = 1;
/**
* User is inactive
*/
case INACTIVE = 0;
}
Every file should begin with this copyright header:
/*
* Copyright (C) Saman beheshtian, Inc - All Rights Reserved
* 2025.
*
* Author Saman beheshtian
* Position Developer
* Email amintado@gmail.com
* Phone +989353466620
* Date 4/8/25, 7:57 PM
*/
/**
* Brief description of class
*
* Detailed description of class functionality and purpose
*
* Error code: [if applicable]
* Singleton: true|false
*/
For service action methods:
/**
* Brief description
*
* Detailed description
*
* return data:
* ```
* [
* 'mobile' => 'string',
* 'name' => 'string'
* ]
* ```
*
* @param string $param1 Description
* @param int $param2 Description
* @return self
* @throws \SomeException
*/
/**
* @property string $name
* @property string $email
* @property int $status
*/
Transaction Management
Model Usage
Error Handling
Metadata Strategy
Test Data Management
protected array $testDatasetUp()Form Testing
set('data', $formData) for Filament formsFlow Testing Structure
Error Scenarios
Use Value Objects
Implement Security Practices
Performance Considerations
Code Consistency