Compare commits
23 Commits
main
...
feature/Up
| Author | SHA1 | Date | |
|---|---|---|---|
| 4afcd5c81e | |||
| e4f7b96b92 | |||
| f072bd1ee8 | |||
| f01992368e | |||
| 161fa3ae1e | |||
| 05c54fb2d7 | |||
| b32ee444ca | |||
| 264ed1ecb9 | |||
| cee480fff5 | |||
| 5024a242d2 | |||
| 0bba710b7d | |||
| f788f9a7ea | |||
| e74619d0ab | |||
| 5b42e23afc | |||
| 51aa3b157c | |||
| b24b61c754 | |||
| 5d2501c71c | |||
| 7fb9e345a2 | |||
| 9d86e329fb | |||
| 4596025ba3 | |||
| 1dbd816da2 | |||
| 52ed10f831 | |||
| e99aa9b8f1 |
@@ -63,3 +63,15 @@ AWS_BUCKET=
|
|||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
FIB_AUTHORIZATION_URL=
|
||||||
|
FIB_CLIENT_ID=
|
||||||
|
FIB_CLIENT_SECRET=
|
||||||
|
|
||||||
|
FIB_CREATE_PAYMENT_URL
|
||||||
|
|
||||||
|
FIB_CHECK_PAYMENT_STATUS_URL
|
||||||
|
|
||||||
|
FIB_CANCEL_PAYMENT_URL
|
||||||
|
|
||||||
|
FIB_REFUND_URL
|
||||||
|
|||||||
@@ -1,28 +1,36 @@
|
|||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie
|
FROM php:8.5.3-fpm-alpine3.23
|
||||||
|
|
||||||
RUN apt-get update \
|
# Install common PHP extension dependencies
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev \
|
RUN apk update && apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
libpng \
|
||||||
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libxml2-dev \
|
||||||
unzip \
|
unzip \
|
||||||
zip \
|
libzip-dev \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
libpq-dev \
|
||||||
&& apt-get clean \
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& docker-php-ext-install pdo_pgsql gd zip
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
#ENV SERVER_NAME=your-domain-name.example.com
|
|
||||||
|
|
||||||
# Copy Laravel application
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Give permissions to storage and bootstrap/cache
|
RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache
|
||||||
RUN chmod -R 777 storage bootstrap/cache
|
|
||||||
|
|
||||||
# Install Composer
|
# Install Composer
|
||||||
COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||||
|
|
||||||
CMD composer install;\
|
# Default command
|
||||||
php artisan key:generate;\
|
CMD composer install ;\
|
||||||
php artisan migrate;\
|
composer dump-autoload --optimize --classmap-authoritative ;\
|
||||||
php artisan db:seed;\
|
php artisan key:generate ;\
|
||||||
frankenphp php-server -r public/
|
php artisan migrate ;\
|
||||||
|
php artisan db:seed ;\
|
||||||
|
php-fpm
|
||||||
|
|||||||
@@ -14,19 +14,28 @@ COPY . .
|
|||||||
|
|
||||||
RUN composer dump-autoload --optimize --classmap-authoritative
|
RUN composer dump-autoload --optimize --classmap-authoritative
|
||||||
|
|
||||||
FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application
|
FROM php:8.5.3-fpm-alpine3.23 AS application
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apk update && apk add --no-cache \
|
||||||
&& apt-get install -y --no-install-recommends libpq-dev unzip zip \
|
bash \
|
||||||
&& install-php-extensions pdo_pgsql pgsql \
|
curl \
|
||||||
&& apt-get clean \
|
libpng \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
freetype-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libpq-dev \
|
||||||
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
|
||||||
|
&& docker-php-ext-install pdo_pgsql gd zip
|
||||||
|
|
||||||
WORKDIR /var/www/payment
|
WORKDIR /var/www/payment
|
||||||
|
|
||||||
COPY --from=builder /app /var/www/payment
|
COPY --from=builder /app /var/www/payment
|
||||||
|
|
||||||
RUN chown -R www-data:www-data /var/www/payment \
|
RUN chown -R www-data:www-data /var/www/payment \
|
||||||
&& chmod -R 775 storage bootstrap/cache
|
&& chmod -R 665 storage bootstrap/cache
|
||||||
|
|
||||||
CMD ["frankenphp", "php-server", "-r", "public/"]
|
CMD ["php-fpm"]
|
||||||
|
|||||||
67
backend/app/Facades/DataTable/DataTable.php
Normal file
67
backend/app/Facades/DataTable/DataTable.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\DataTableInput;
|
||||||
|
use App\Services\DataTable\DataTableService;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidParameterInterface;
|
||||||
|
|
||||||
|
class DataTable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Extracts data from request, passes to datatable service and prepares data for response.
|
||||||
|
* @param Model|Builder $mixed
|
||||||
|
* @param Request $request
|
||||||
|
* @param array $allowedFilters
|
||||||
|
* @param array $allowedRelations
|
||||||
|
* @param array $allowedSortings
|
||||||
|
* @param array $allowedSelects
|
||||||
|
* @return array
|
||||||
|
* @throws InvalidParameterInterface if input parameters are invalid.
|
||||||
|
*/
|
||||||
|
public function run(
|
||||||
|
Model|Builder $mixed,
|
||||||
|
Request $request,
|
||||||
|
array $allowedFilters = [],
|
||||||
|
array $allowedRelations = [],
|
||||||
|
array $allowedSortings = [],
|
||||||
|
array $allowedSelects = [],
|
||||||
|
array $allowedGroupBy = []
|
||||||
|
): array
|
||||||
|
{
|
||||||
|
|
||||||
|
$filters = json_decode($request->filters);
|
||||||
|
$sorting = json_decode($request->sorting);
|
||||||
|
$rels = $request->rels ?: array();
|
||||||
|
|
||||||
|
$dataTableInput = new DataTableInput(
|
||||||
|
$request->start,
|
||||||
|
$request->size,
|
||||||
|
$filters,
|
||||||
|
$sorting,
|
||||||
|
$rels,
|
||||||
|
$allowedFilters,
|
||||||
|
$allowedSortings,
|
||||||
|
$allowedGroupBy
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = $this->makeQueryFromModel($mixed);
|
||||||
|
|
||||||
|
$dataTableService = (new DataTableService($query, $dataTableInput))
|
||||||
|
->setAllowedFilters($allowedFilters)
|
||||||
|
->setAllowedRelations($allowedRelations)
|
||||||
|
->setAllowedSortings($allowedSortings)
|
||||||
|
->setAllowedSelects($allowedSelects)
|
||||||
|
->setAllowedGroupBy($allowedGroupBy);
|
||||||
|
|
||||||
|
return $dataTableService->getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function makeQueryFromModel(Model|Builder $mixed): Builder
|
||||||
|
{
|
||||||
|
return ($mixed instanceof Model) ? $mixed->query() : $mixed;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
backend/app/Facades/DataTable/DataTableFacade.php
Normal file
13
backend/app/Facades/DataTable/DataTableFacade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\DataTable;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class DataTableFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor(): string
|
||||||
|
{
|
||||||
|
return DataTable::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
113
backend/app/Facades/File/File.php
Normal file
113
backend/app/Facades/File/File.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\File;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Http\File as HttpFile;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
class File
|
||||||
|
{
|
||||||
|
public function save(HttpFile|UploadedFile $file, string $path, string $name = null, string $disk = 'public'): string
|
||||||
|
{
|
||||||
|
return Storage::disk($disk)->putFileAs(
|
||||||
|
$path,
|
||||||
|
$file,
|
||||||
|
$name ?? Str::uuid() . '.' . $file->extension()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $filePath
|
||||||
|
* @param bool $url_is_absolute
|
||||||
|
* @param string $disk
|
||||||
|
* @return void
|
||||||
|
* @throws InvalidArgumentException when filePath is empty.
|
||||||
|
*/
|
||||||
|
public function delete(string $filePath, bool $url_is_absolute = false, string $disk = 'public'): void
|
||||||
|
{
|
||||||
|
if (!$filePath){
|
||||||
|
throw new InvalidArgumentException('File path is invalid.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($url_is_absolute) {
|
||||||
|
$needle = 'storage/';
|
||||||
|
$pos = strpos($filePath, $needle);
|
||||||
|
$filePath = substr($filePath, $pos + strlen($needle));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Storage::disk($disk)->exists($filePath)) {
|
||||||
|
Storage::disk($disk)->delete($filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteContent($file_path): bool
|
||||||
|
{
|
||||||
|
if (file_exists($file_path)) {
|
||||||
|
file_put_contents($file_path, '');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tail($file_path, $lines = 100, $buffer = 2048): bool|string
|
||||||
|
{
|
||||||
|
// Open file
|
||||||
|
$file = @fopen($file_path, "rb");
|
||||||
|
if ($file === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jump to last character
|
||||||
|
fseek($file, -1, SEEK_END);
|
||||||
|
|
||||||
|
// Read it and adjust line number if necessary
|
||||||
|
// (Otherwise the result would be wrong if file doesn't end with a blank line)
|
||||||
|
if (fread($file, 1) != "\n") {
|
||||||
|
$lines -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start reading
|
||||||
|
$output = '';
|
||||||
|
$chunk = '';
|
||||||
|
|
||||||
|
// While we would like more
|
||||||
|
while (ftell($file) > 0 && $lines >= 0) {
|
||||||
|
|
||||||
|
// Figure out how far back we should jump
|
||||||
|
$seek = min(ftell($file), $buffer);
|
||||||
|
|
||||||
|
// Do the jump (backwards, relative to where we are)
|
||||||
|
fseek($file, -$seek, SEEK_CUR);
|
||||||
|
|
||||||
|
// Read a chunk and prepend it to our output
|
||||||
|
$output = ($chunk = fread($file, $seek)) . $output;
|
||||||
|
|
||||||
|
// Jump back to where we started reading
|
||||||
|
fseek($file, -mb_strlen($chunk, '8bit'), SEEK_CUR);
|
||||||
|
|
||||||
|
// Decrease our line counter
|
||||||
|
$lines -= substr_count($chunk, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// While we have too many lines
|
||||||
|
// (Because of buffer size we might have read too many)
|
||||||
|
while ($lines++ < 0) {
|
||||||
|
|
||||||
|
// Find first newline and remove all text before that
|
||||||
|
$output = substr($output, strpos($output, "\n") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close file and return
|
||||||
|
fclose($file);
|
||||||
|
return trim($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteDirectory(string $path, string $disk = 'public'): void
|
||||||
|
{
|
||||||
|
Storage::disk($disk)->deleteDirectory($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
backend/app/Facades/File/FileFacade.php
Normal file
13
backend/app/Facades/File/FileFacade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\File;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
class FileFacade extends Facade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor(): string
|
||||||
|
{
|
||||||
|
return File::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
backend/app/Mail/LoginNotificationMail.php
Normal file
40
backend/app/Mail/LoginNotificationMail.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class LoginNotificationMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public User $user
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Login Notification Mail',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: 'emails.login-notification',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
22
backend/app/Models/User.php
Normal file → Executable file
22
backend/app/Models/User.php
Normal file → Executable file
@@ -5,28 +5,18 @@ namespace App\Models;
|
|||||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Database\Factories\UserFactory;
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Passport\HasApiTokens;
|
||||||
|
|
||||||
#[Fillable(['name', 'email', 'password'])]
|
#[Guarded(['id'])]
|
||||||
#[Hidden(['password', 'remember_token'])]
|
#[Hidden(['password'])]
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory, Notifiable;
|
use HasFactory, Notifiable, HasApiTokens;
|
||||||
|
protected $guarded = ['id'];
|
||||||
/**
|
|
||||||
* Get the attributes that should be cast.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
protected function casts(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'email_verified_at' => 'datetime',
|
|
||||||
'password' => 'hashed',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
backend/app/Providers/AppServiceProvider.php
Normal file → Executable file
5
backend/app/Providers/AppServiceProvider.php
Normal file → Executable file
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
|
use Carbon\CarbonInterval;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -19,6 +21,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
Passport::enablePasswordGrant();
|
||||||
|
Passport::personalAccessTokensExpireIn(CarbonInterval::minutes(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
backend/app/Providers/DataTableServiceProvider.php
Normal file
27
backend/app/Providers/DataTableServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Facades\DataTable\DataTable;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class DataTableServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->bind('datatable', function () {
|
||||||
|
return new DataTable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
27
backend/app/Providers/FileServiceProvider.php
Normal file
27
backend/app/Providers/FileServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Facades\File\File;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class FileServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->app->bind('file', function () {
|
||||||
|
return new File();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
83
backend/app/Services/DataTable/DataTableInput.php
Normal file
83
backend/app/Services/DataTable/DataTableInput.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Filter\Filter;
|
||||||
|
use App\Services\DataTable\Sort\Sort;
|
||||||
|
|
||||||
|
class DataTableInput
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param int $start
|
||||||
|
* @param int $size
|
||||||
|
* @param array $filters
|
||||||
|
* @param array $sorting
|
||||||
|
* @param array $rels
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private ?int $start,
|
||||||
|
private ?int $size,
|
||||||
|
private array $filters,
|
||||||
|
private ?array $sorting,
|
||||||
|
private array $rels,
|
||||||
|
private array $allowedFilters,
|
||||||
|
private array $allowedSortings,
|
||||||
|
private ?array $GroupBy,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStart(): ?int
|
||||||
|
{
|
||||||
|
return $this->start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSize(): ?int
|
||||||
|
{
|
||||||
|
return $this->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array returns an array of Filter objects
|
||||||
|
*/
|
||||||
|
public function getFilters(): array
|
||||||
|
{
|
||||||
|
$filters = array();
|
||||||
|
|
||||||
|
foreach ($this->filters as $filter) {
|
||||||
|
$filters[] = new Filter(
|
||||||
|
$filter->id,
|
||||||
|
$filter->value,
|
||||||
|
$filter->fn,
|
||||||
|
$filter->datatype,
|
||||||
|
$this->allowedFilters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSorting(): ?array
|
||||||
|
{
|
||||||
|
$sorts = [];
|
||||||
|
if (!empty($this->sorting)){
|
||||||
|
foreach ($this->sorting as $sort) {
|
||||||
|
$sorts[] = new Sort($sort->id, $sort->desc, $this->allowedSortings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sorts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelations(): array
|
||||||
|
{
|
||||||
|
return $this->rels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGroupBy(): ?array
|
||||||
|
{
|
||||||
|
return $this->GroupBy;
|
||||||
|
}
|
||||||
|
}
|
||||||
128
backend/app/Services/DataTable/DataTableService.php
Normal file
128
backend/app/Services/DataTable/DataTableService.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Filter\ApplyFilter;
|
||||||
|
use App\Services\DataTable\Sort\ApplySort;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class DataTableService
|
||||||
|
{
|
||||||
|
|
||||||
|
protected array $allowedFilters;
|
||||||
|
protected array $allowedRelations;
|
||||||
|
protected array $allowedSortings;
|
||||||
|
protected array $allowedSelects;
|
||||||
|
protected array $allowedGroupBy;
|
||||||
|
private int $totalRowCount;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
protected Builder $query,
|
||||||
|
private DataTableInput $dataTableInput
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedFilters(array $allowedFilters): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedFilters = $allowedFilters;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedRelations(array $allowedRelations): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedRelations = $allowedRelations;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedSortings(array $allowedSortings): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedSortings = $allowedSortings;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedSelects(array $allowedSelects): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedSelects = $allowedSelects;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAllowedGroupBy(array $allowedGroupBy): DataTableService
|
||||||
|
{
|
||||||
|
$this->allowedGroupBy = $allowedGroupBy;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle 'getData' operations
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
$query = $this->buildQuery();
|
||||||
|
$data = $query->get();
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'data' => $data,
|
||||||
|
'meta' => [
|
||||||
|
'totalRowCount' => $this->totalRowCount
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildQuery(): Builder
|
||||||
|
{
|
||||||
|
$query = $this->query;
|
||||||
|
|
||||||
|
foreach ($this->dataTableInput->getFilters() as $filter) {
|
||||||
|
$query = (new ApplyFilter($query, $filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->applySelect($query, $this->allowedSelects);
|
||||||
|
$query = $this->includeRelationsInQuery($query, $this->allowedRelations);
|
||||||
|
$query = $this->applyGroupBy($query, $this->allowedGroupBy);
|
||||||
|
|
||||||
|
$this->totalRowCount = $query->count();
|
||||||
|
|
||||||
|
if (!is_null($this->dataTableInput->getStart())) {
|
||||||
|
$query->offset($this->dataTableInput->getStart());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_null($this->dataTableInput->getSize())){
|
||||||
|
$query->limit($this->dataTableInput->getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
$sorting = $this->dataTableInput->getSorting();
|
||||||
|
foreach ($sorting as $sort){
|
||||||
|
$query = (new ApplySort($query, $sort))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function applySelect(Builder $query, array $selectedFields): Builder
|
||||||
|
{
|
||||||
|
if (!empty($selectedFields)) {
|
||||||
|
$query->select($selectedFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function applyGroupBy(Builder $query, array $groupBy): Builder
|
||||||
|
{
|
||||||
|
return empty($groupBy) ? $query : $query->groupBy($groupBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function includeRelationsInQuery(Builder $query, array $rels): Builder
|
||||||
|
{
|
||||||
|
if (!empty($rels)) {
|
||||||
|
$query->with($rels);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (later) define mapping of relation names to prevent relation name expose.
|
||||||
|
// (later) define mapping of column names to prevent column name expose.
|
||||||
|
}
|
||||||
15
backend/app/Services/DataTable/Enums/DataType.php
Normal file
15
backend/app/Services/DataTable/Enums/DataType.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Enums;
|
||||||
|
|
||||||
|
enum DataType: string
|
||||||
|
{
|
||||||
|
case NUMERIC = 'numeric';
|
||||||
|
case TEXT = 'text';
|
||||||
|
case DATE = 'date';
|
||||||
|
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return array_column(self::cases(), 'value');
|
||||||
|
}
|
||||||
|
}
|
||||||
19
backend/app/Services/DataTable/Enums/SearchType.php
Normal file
19
backend/app/Services/DataTable/Enums/SearchType.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Enums;
|
||||||
|
|
||||||
|
enum SearchType: string
|
||||||
|
{
|
||||||
|
case CONTAINS = 'contains';
|
||||||
|
case EQUALS = 'equals';
|
||||||
|
case NOT_EQUALS = 'notEquals';
|
||||||
|
case BETWEEN = 'between';
|
||||||
|
case GREATER_THAN = 'greaterThan';
|
||||||
|
case LESS_THAN = 'lessThan';
|
||||||
|
case FUZZY = 'fuzzy';
|
||||||
|
|
||||||
|
public static function values(): array
|
||||||
|
{
|
||||||
|
return array_column(self::cases(), 'value');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidFilterException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
interface InvalidParameterInterface
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidRelationException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class InvalidSortingException extends Exception implements InvalidParameterInterface
|
||||||
|
{
|
||||||
|
protected $fieldName;
|
||||||
|
|
||||||
|
public function __construct($fieldName, $message = "", $code = 400, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
$this->fieldName = $fieldName;
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFieldName()
|
||||||
|
{
|
||||||
|
return $this->fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
84
backend/app/Services/DataTable/Filter/ApplyFilter.php
Normal file
84
backend/app/Services/DataTable/Filter/ApplyFilter.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\SearchType;
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidFilterException;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterBetween;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterContains;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterEquals;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterGreaterThan;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterLessThan;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\FilterNotEquals;
|
||||||
|
use App\Services\DataTable\Filter\SearchFunctions\SearchFilter;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class ApplyFilter
|
||||||
|
{
|
||||||
|
private SearchFilter $searchFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $query
|
||||||
|
* @param Filter $filter
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private Builder $query,
|
||||||
|
private Filter $filter,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$filter = $this->filter;
|
||||||
|
$query = $this->query;
|
||||||
|
|
||||||
|
$searchType = SearchType::from($filter->getFn());
|
||||||
|
switch ($searchType) {
|
||||||
|
case SearchType::CONTAINS:
|
||||||
|
$this->searchFilter = new FilterContains($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::EQUALS:
|
||||||
|
$this->searchFilter = new FilterEquals($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::NOT_EQUALS:
|
||||||
|
$this->searchFilter = new FilterNotEquals($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::BETWEEN:
|
||||||
|
$this->searchFilter = new FilterBetween($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::GREATER_THAN:
|
||||||
|
$this->searchFilter = new FilterGreaterThan($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SearchType::LESS_THAN:
|
||||||
|
$this->searchFilter = new FilterLessThan($query, $filter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$searchFunction = $filter->getFn();
|
||||||
|
throw new InvalidFilterException($searchFunction, "search function `$searchFunction` is invalid.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$relation = $this->filter->getRelation();
|
||||||
|
return method_exists($this->query->getModel(), $relation) ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function applyFilterToRelation(string $relation): Builder
|
||||||
|
{
|
||||||
|
return $this->query->whereHas($relation, function (Builder $query) {
|
||||||
|
$this->filter->removeRelationFromId();
|
||||||
|
$this->applyFilter($query, $this->filter);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyFilter(Builder $query, Filter $filter): Builder
|
||||||
|
{
|
||||||
|
return (new ApplyFilter($query, $filter))->apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
73
backend/app/Services/DataTable/Filter/Filter.php
Normal file
73
backend/app/Services/DataTable/Filter/Filter.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Validators\FilterValidator;
|
||||||
|
|
||||||
|
class Filter
|
||||||
|
{
|
||||||
|
private static FilterValidator $filterValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @param string|int|array $value
|
||||||
|
* @param string $fn
|
||||||
|
* @param string $datatype
|
||||||
|
* @param array $allowedFilters
|
||||||
|
* @throws \App\Services\DataTable\Exceptions\InvalidFilterException
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private string $id,
|
||||||
|
private string|int|array $value,
|
||||||
|
private string $fn,
|
||||||
|
private string $datatype,
|
||||||
|
private array $allowedFilters
|
||||||
|
)
|
||||||
|
{
|
||||||
|
self::$filterValidator = FilterValidator::getInstance();
|
||||||
|
self::$filterValidator->isValid($this, $this->allowedFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValue(): array|int|string
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFn(): string
|
||||||
|
{
|
||||||
|
return $this->fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatatype(): string
|
||||||
|
{
|
||||||
|
return $this->datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRelation(): string
|
||||||
|
{
|
||||||
|
$fieldArray = explode('.', $this->id);
|
||||||
|
return count($fieldArray) > 1 ? $fieldArray[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColumn(): string
|
||||||
|
{
|
||||||
|
$fieldArray = explode('.', $this->id);
|
||||||
|
return array_pop($fieldArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeRelationFromId(): void
|
||||||
|
{
|
||||||
|
$this->id = $this->getColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValue(int|array|string $value): void
|
||||||
|
{
|
||||||
|
$this->value = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterBetween extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$query = $this->query;
|
||||||
|
[$minVal, $maxVal] = $this->filter->getValue();
|
||||||
|
|
||||||
|
if ($minVal) {
|
||||||
|
if ($this->filter->getDatatype() == "date") {
|
||||||
|
$minVal = $minVal . " 00:00:00";
|
||||||
|
}
|
||||||
|
$this->filter->setValue($minVal);
|
||||||
|
$query = (new FilterGreaterThanOrEqual($this->query, $this->filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($maxVal) {
|
||||||
|
if ($this->filter->getDatatype() == "date") {
|
||||||
|
$maxVal = $maxVal . " 23:59:59";
|
||||||
|
}
|
||||||
|
$this->filter->setValue($maxVal);
|
||||||
|
$query = (new FilterLessThanOrEqual($this->query, $this->filter))->apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterContains extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$column = $this->filter->getId();
|
||||||
|
$value = '%' . $this->filter->getValue() . '%';
|
||||||
|
|
||||||
|
if ($this->filter->getDatatype() == DataType::TEXT->value) {
|
||||||
|
$query = $this->searchIgnoreCase($column, $value);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$query = $this->query->where($column, 'LIKE', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function searchIgnoreCase(string $column, string $value): Builder
|
||||||
|
{
|
||||||
|
$value = strtolower($value);
|
||||||
|
return $this->query->whereRaw("LOWER($column) LIKE ?", [$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterEquals extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$column = $this->filter->getId();
|
||||||
|
$value = $this->filter->getValue();
|
||||||
|
|
||||||
|
if ($this->filter->getDatatype() == DataType::TEXT->value) {
|
||||||
|
$query = $this->searchIgnoreCase($column, $value);
|
||||||
|
} else {
|
||||||
|
$query = $this->query->where($column, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function searchIgnoreCase(string $column, string $value): Builder
|
||||||
|
{
|
||||||
|
$value = strtolower($value);
|
||||||
|
return $this->query->whereRaw("LOWER($column) = ?", [$value]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterGreaterThan extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$value = ($this->filter->getDatatype() == DataType::NUMERIC) ?
|
||||||
|
(float)$this->filter->getValue() : $this->filter->getValue();
|
||||||
|
|
||||||
|
return $this->query->where($this->filter->getId(), '>', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterGreaterThanOrEqual extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$value = ($this->filter->getDatatype() == DataType::NUMERIC) ?
|
||||||
|
(float)$this->filter->getValue() : $this->filter->getValue();
|
||||||
|
|
||||||
|
return $this->query->where($this->filter->getId(), '>=', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterLessThan extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$value = ($this->filter->getDatatype() == DataType::NUMERIC) ?
|
||||||
|
(float)$this->filter->getValue() : $this->filter->getValue();
|
||||||
|
|
||||||
|
return $this->query->where($this->filter->getId(), '<', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterLessThanOrEqual extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$value = ($this->filter->getDatatype() == DataType::NUMERIC) ?
|
||||||
|
(float)$this->filter->getValue() : $this->filter->getValue();
|
||||||
|
|
||||||
|
return $this->query->where($this->filter->getId(), '<=', $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class FilterNotEquals extends SearchFilter
|
||||||
|
{
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$column = $this->filter->getId();
|
||||||
|
$value = $this->filter->getValue();
|
||||||
|
|
||||||
|
return $this->query->whereNot($column, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Filter\SearchFunctions;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Filter\Filter;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
abstract class SearchFilter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param Builder $query
|
||||||
|
* @param Filter $filter
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
protected Builder $query,
|
||||||
|
protected Filter $filter,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract public function apply(): Builder;
|
||||||
|
}
|
||||||
31
backend/app/Services/DataTable/Sort/ApplySort.php
Normal file
31
backend/app/Services/DataTable/Sort/ApplySort.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Sort;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class ApplySort
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Builder $query
|
||||||
|
* @param ?Sort $sort
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private Builder $query,
|
||||||
|
private ?Sort $sort,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(): Builder
|
||||||
|
{
|
||||||
|
$query = $this->query;
|
||||||
|
|
||||||
|
if (!is_null($this->sort)) {
|
||||||
|
$query->orderBy($this->sort->getId(), $this->sort->getDirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
backend/app/Services/DataTable/Sort/Sort.php
Normal file
39
backend/app/Services/DataTable/Sort/Sort.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Sort;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Validators\SortingValidator;
|
||||||
|
|
||||||
|
class Sort
|
||||||
|
{
|
||||||
|
private static SortingValidator $sortingValidator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $id
|
||||||
|
* @param bool $desc
|
||||||
|
* @param array $allowedSortings
|
||||||
|
* @throws \App\Services\DataTable\Exceptions\InvalidSortingException
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
private string $id,
|
||||||
|
private bool $desc,
|
||||||
|
private array $allowedSortings,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
self::$sortingValidator = SortingValidator::getInstance();
|
||||||
|
self::$sortingValidator->isValid($this, $this->allowedSortings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId(): string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDirection(): string
|
||||||
|
{
|
||||||
|
return $this->desc === true ? 'desc' : 'asc';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Validators;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Enums\SearchType;
|
||||||
|
use App\Services\DataTable\Enums\DataType;
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidFilterException;
|
||||||
|
use App\Services\DataTable\Filter\Filter;
|
||||||
|
|
||||||
|
class FilterValidator
|
||||||
|
{
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInstance(): FilterValidator
|
||||||
|
{
|
||||||
|
if (!isset(self::$instance)) {
|
||||||
|
self::$instance = new static();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isValid(Filter $filter, array $allowedFilters): bool
|
||||||
|
{
|
||||||
|
if (!$this->isAllowed($filter, $allowedFilters)) {
|
||||||
|
$filterId = $filter->getId();
|
||||||
|
throw new InvalidFilterException($filter->getId(), "filtering field `$filterId` is not allowed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->isValidSearchFunction($filter)) {
|
||||||
|
$searchFunction = $filter->getFn();
|
||||||
|
throw new InvalidFilterException($searchFunction, "search function `$searchFunction` is invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isValidDataType($filter) == -1) {
|
||||||
|
throw new InvalidFilterException(null, "datatype property is not set in `filters` array.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->isValidDataType($filter)) {
|
||||||
|
$datatype = $filter->getDatatype();
|
||||||
|
throw new InvalidFilterException($datatype, "datatype `$datatype` is invalid.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isAllowed(Filter $filter, array $allowedFilters): bool
|
||||||
|
{
|
||||||
|
return $allowedFilters == ['*'] || in_array($filter->getId(), $allowedFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isValidSearchFunction(Filter $filter): bool
|
||||||
|
{
|
||||||
|
$searchFunction = $filter->getFn();
|
||||||
|
return isset($searchFunction) && in_array($searchFunction, SearchType::values());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isValidDataType(Filter $filter): int
|
||||||
|
{
|
||||||
|
if (!property_exists($filter, 'datatype'))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return $filter->getDatatype() && in_array($filter->getDatatype(), DataType::values()) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Validators;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidRelationException;
|
||||||
|
|
||||||
|
class RelationValidator
|
||||||
|
{
|
||||||
|
public static function validate(?array $rels, array $allowedRelations): bool
|
||||||
|
{
|
||||||
|
foreach ($rels as $relation) {
|
||||||
|
|
||||||
|
if (!self::isAllowed($relation, $allowedRelations)) {
|
||||||
|
throw new InvalidRelationException($relation, "relation `$relation` is not allowed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isAllowed(string $relation, array $allowedRelations): bool
|
||||||
|
{
|
||||||
|
return !$relation || in_array($relation, $allowedRelations);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\DataTable\Validators;
|
||||||
|
|
||||||
|
use App\Services\DataTable\Exceptions\InvalidSortingException;
|
||||||
|
use App\Services\DataTable\Sort\Sort;
|
||||||
|
|
||||||
|
class SortingValidator
|
||||||
|
{
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInstance(): SortingValidator
|
||||||
|
{
|
||||||
|
if (!isset(self::$instance)) {
|
||||||
|
self::$instance = new static();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isValid(Sort $sorting, array $allowedSortings): bool
|
||||||
|
{
|
||||||
|
if (!$this->isAllowed($sorting, $allowedSortings)) {
|
||||||
|
$sortId = $sorting->getId();
|
||||||
|
throw new InvalidSortingException($sortId, "sorting field `$sortId` is not allowed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isAllowed(Sort $sorting, array $allowedSortings): bool
|
||||||
|
{
|
||||||
|
return $allowedSortings == ['*'] || in_array($sorting->getId(), $allowedSortings);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
backend/app/Traits/ApiResponse.php
Executable file
31
backend/app/Traits/ApiResponse.php
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
trait ApiResponse
|
||||||
|
{
|
||||||
|
public function successResponse(mixed $data = null, string $message = null, int $statusCode = 200): JsonResponse
|
||||||
|
{
|
||||||
|
if (!is_null($data)) {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $data
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $message ?? __('messages.successful');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function errorResponse(string $message, string $type = 'logical_exception', int $statusCode = 422): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'type' => $type,
|
||||||
|
'message' => $message
|
||||||
|
], $statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
backend/app/User/Controller/Auth/AuthController.php
Executable file
65
backend/app/User/Controller/Auth/AuthController.php
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controller\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Auth\LoginRequest;
|
||||||
|
use App\User\Requests\Auth\RegisterRequest;
|
||||||
|
use App\User\Resources\UserResource;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function register(RegisterRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
User::query()->create([
|
||||||
|
'username' => $request->username,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(LoginRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$credentials = ['password' => $request->password,];
|
||||||
|
|
||||||
|
if (filter_var($request->login, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$credentials['email'] = $request->login;
|
||||||
|
} else {
|
||||||
|
$credentials['username'] = $request->login;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Auth::attempt($credentials))
|
||||||
|
{
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return $this->successResponse(new UserResource($user));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->errorResponse(__('messages.incorrect_or_username_password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
Auth::logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
backend/app/User/Controller/Dashboard/ConfirmController.php
Executable file
14
backend/app/User/Controller/Dashboard/ConfirmController.php
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controller\Dashboard;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ConfirmController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
56
backend/app/User/Controller/ProfileController.php
Normal file
56
backend/app/User/Controller/ProfileController.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controller;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Profile\ChangePasswordRequest;
|
||||||
|
use App\User\Requests\Profile\EditRequest;
|
||||||
|
use App\User\Resources\UserResource;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function info(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(new UserResource(Auth::user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(EditRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'first_name' => $request->first_name,
|
||||||
|
'last_name' => $request->last_name,
|
||||||
|
'national_id' => $request->national_id,
|
||||||
|
'address' => $request->address,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
'status' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function changePassword(ChangePasswordRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
if (! Hash::check($request->current_password, $user->password)) {
|
||||||
|
return $this->errorResponse(__('messages.incorrect_current_password'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($request->new_password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
23
backend/app/User/Events/LoginEmailEvent.php
Executable file
23
backend/app/User/Events/LoginEmailEvent.php
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Events;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class LoginEmailEvent
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*/
|
||||||
|
public function __construct(public User $user)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
31
backend/app/User/Listeners/SendEmailListener.php
Executable file
31
backend/app/User/Listeners/SendEmailListener.php
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Listeners;
|
||||||
|
|
||||||
|
use App\Mail\LoginNotificationMail;
|
||||||
|
use App\User\Events\LoginEmailEvent;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class SendEmailListener implements ShouldQueue{
|
||||||
|
public string $queue = 'emails';
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*/
|
||||||
|
public function handle(LoginEmailEvent $event): void
|
||||||
|
{
|
||||||
|
$user = $event->user;
|
||||||
|
|
||||||
|
Mail::to($user->email)->send(
|
||||||
|
new LoginNotificationMail($user)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
backend/app/User/Requests/Auth/LoginRequest.php
Executable file
29
backend/app/User/Requests/Auth/LoginRequest.php
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class LoginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'login' => 'required|string',
|
||||||
|
'password' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/app/User/Requests/Auth/RegisterRequest.php
Executable file
30
backend/app/User/Requests/Auth/RegisterRequest.php
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class RegisterRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'username' => 'required|unique:users,username',
|
||||||
|
'email' => 'required|email|unique:users,email',
|
||||||
|
'password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6|confirmed:',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
backend/app/User/Requests/Profile/ChangePasswordRequest.php
Normal file
30
backend/app/User/Requests/Profile/ChangePasswordRequest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class ChangePasswordRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
|
||||||
|
'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
36
backend/app/User/Requests/Profile/EditRequest.php
Normal file
36
backend/app/User/Requests/Profile/EditRequest.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Profile;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class EditRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => 'required|string',
|
||||||
|
'last_name' => 'required|string',
|
||||||
|
'national_id' => 'required',
|
||||||
|
'address' => 'required',
|
||||||
|
'postal_code' => 'required',
|
||||||
|
'phone_number' => 'required',
|
||||||
|
'province_id' => 'required',
|
||||||
|
'city_id' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
backend/app/User/Resources/UserResource.php
Executable file
23
backend/app/User/Resources/UserResource.php
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class UserResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'username' => $this->username,
|
||||||
|
'email' => $this->email,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
58
backend/app/User/Services/FIB/AuthorizationService.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class AuthorizationService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.authorization.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
$this->inputParameters = [
|
||||||
|
'client_id' => config('fib.authorization.client_id'),
|
||||||
|
'client_secret' => config('fib.authorization.client_secret'),
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::asForm()
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url, $this->inputParameters)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
62
backend/app/User/Services/FIB/CancelPaymentService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CancelPaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.cancelPayment.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
51
backend/app/User/Services/FIB/CheckPaymentStatusService.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CheckPaymentStatusService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.checkPaymentStatus.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
73
backend/app/User/Services/FIB/CreatePaymentService.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CreatePaymentService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
protected array $inputParameters;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.createPayment.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccessToken(string $accessToken): void
|
||||||
|
{
|
||||||
|
$this->accessToken = $accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setInputParameters(array $inputParameters): void
|
||||||
|
{
|
||||||
|
$this->inputParameters = $inputParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url, $this->inputParameters)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
backend/app/User/Services/FIB/RefundService.php
Normal file
62
backend/app/User/Services/FIB/RefundService.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Services\FIB;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class RefundService
|
||||||
|
{
|
||||||
|
protected string $url;
|
||||||
|
protected string $channelName;
|
||||||
|
protected string $accessToken;
|
||||||
|
protected array $headers;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->url = config('fib.refund.url');
|
||||||
|
$this->channelName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHeaders(): void
|
||||||
|
{
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function run(): array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->sendRequest();
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Log::channel($this->channelName)
|
||||||
|
->error(get_class($this),
|
||||||
|
[
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectionException
|
||||||
|
*/
|
||||||
|
public function sendRequest(): array
|
||||||
|
{
|
||||||
|
return Http::withHeaders($this->headers)
|
||||||
|
->throw()
|
||||||
|
->withoutVerifying()
|
||||||
|
->post($this->url)
|
||||||
|
->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
backend/bootstrap/app.php
Normal file → Executable file
8
backend/bootstrap/app.php
Normal file → Executable file
@@ -7,12 +7,16 @@ use Illuminate\Foundation\Configuration\Middleware;
|
|||||||
return Application::configure(basePath: dirname(__DIR__))
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
->withRouting(
|
->withRouting(
|
||||||
web: __DIR__.'/../routes/web.php',
|
web: __DIR__.'/../routes/web.php',
|
||||||
|
api: __DIR__.'/../routes/api.php',
|
||||||
commands: __DIR__.'/../routes/console.php',
|
commands: __DIR__.'/../routes/console.php',
|
||||||
health: '/up',
|
health: '/up',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
//
|
$middleware->web()->validateCsrfTokens(['*']);
|
||||||
})
|
})
|
||||||
->withExceptions(function (Exceptions $exceptions): void {
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
//
|
//
|
||||||
})->create();
|
})
|
||||||
|
->withEvents(discover: [
|
||||||
|
__DIR__.'/../app/User/Listeners',
|
||||||
|
])->create();
|
||||||
|
|||||||
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
0
backend/bootstrap/cache/.gitignore
vendored
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Providers\AppServiceProvider;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\DataTableServiceProvider::class,
|
||||||
|
App\Providers\FileServiceProvider::class,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
"laravel/framework": "^13.0",
|
"laravel/framework": "^13.0",
|
||||||
|
"laravel/passport": "^13.0",
|
||||||
"laravel/tinker": "^3.0"
|
"laravel/tinker": "^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|||||||
1010
backend/composer.lock
generated
1010
backend/composer.lock
generated
File diff suppressed because it is too large
Load Diff
4
backend/config/auth.php
Normal file → Executable file
4
backend/config/auth.php
Normal file → Executable file
@@ -42,6 +42,10 @@ return [
|
|||||||
'driver' => 'session',
|
'driver' => 'session',
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
],
|
],
|
||||||
|
'api' => [
|
||||||
|
'driver' => 'passport',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
34
backend/config/cors.php
Executable file
34
backend/config/cors.php
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure your settings for cross-origin resource sharing
|
||||||
|
| or "CORS". This determines what cross-origin operations may execute
|
||||||
|
| in web browsers. You are free to adjust these settings as needed.
|
||||||
|
|
|
||||||
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'paths' => ['*'],
|
||||||
|
|
||||||
|
'allowed_methods' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins_patterns' => [],
|
||||||
|
|
||||||
|
'allowed_headers' => ['*'],
|
||||||
|
|
||||||
|
'exposed_headers' => [],
|
||||||
|
|
||||||
|
'max_age' => 0,
|
||||||
|
|
||||||
|
'supports_credentials' => true,
|
||||||
|
|
||||||
|
];
|
||||||
25
backend/config/fib.php
Normal file
25
backend/config/fib.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'authorization' => [
|
||||||
|
'url' => env('FIB_AUTHORIZATION_URL'),
|
||||||
|
'client_id' => env('FIB_CLIENT_ID'),
|
||||||
|
'client_secret' => env('FIB_CLIENT_SECRET'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'createPayment' => [
|
||||||
|
'url' => env('FIB_CREATE_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'checkPaymentStatus' => [
|
||||||
|
'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cancelPayment' => [
|
||||||
|
'url' => env('FIB_CANCEL_PAYMENT_URL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'refund' => [
|
||||||
|
'url' => env('FIB_REFUND_URL'),
|
||||||
|
],
|
||||||
|
];
|
||||||
48
backend/config/passport.php
Normal file
48
backend/config/passport.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Passport Guard
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which authentication guard Passport will use when
|
||||||
|
| authenticating users. This value should correspond with one of your
|
||||||
|
| guards that is already present in your "auth" configuration file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guard' => 'web',
|
||||||
|
|
||||||
|
'middleware' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Keys
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Passport uses encryption keys while generating secure access tokens for
|
||||||
|
| your application. By default, the keys are stored as local files but
|
||||||
|
| can be set via environment variables when that is more convenient.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'private_key' => env('PASSPORT_PRIVATE_KEY'),
|
||||||
|
|
||||||
|
'public_key' => env('PASSPORT_PUBLIC_KEY'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Passport Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, Passport's models will utilize your application's default
|
||||||
|
| database connection. If you wish to use a different connection you
|
||||||
|
| may specify the configured name of the database connection here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('PASSPORT_CONNECTION'),
|
||||||
|
|
||||||
|
];
|
||||||
0
backend/config/session.php
Normal file → Executable file
0
backend/config/session.php
Normal file → Executable file
2
backend/database/factories/UserFactory.php
Normal file → Executable file
2
backend/database/factories/UserFactory.php
Normal file → Executable file
@@ -25,7 +25,7 @@ class UserFactory extends Factory
|
|||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => fake()->name(),
|
'username' => fake()->name(),
|
||||||
'email' => fake()->unique()->safeEmail(),
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
'password' => static::$password ??= Hash::make('password'),
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
|||||||
24
backend/database/migrations/0001_01_01_000000_create_users_table.php
Normal file → Executable file
24
backend/database/migrations/0001_01_01_000000_create_users_table.php
Normal file → Executable file
@@ -13,18 +13,23 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('users', function (Blueprint $table) {
|
Schema::create('users', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('username');
|
||||||
|
$table->string('first_name')->nullable();
|
||||||
|
$table->string('last_name')->nullable();
|
||||||
$table->string('email')->unique();
|
$table->string('email')->unique();
|
||||||
$table->timestamp('email_verified_at')->nullable();
|
|
||||||
$table->string('password');
|
$table->string('password');
|
||||||
$table->rememberToken();
|
$table->tinyInteger('status')->default(0);
|
||||||
$table->timestamps();
|
$table->string('national_id')->nullable();
|
||||||
});
|
$table->string('address')->nullable();
|
||||||
|
$table->string('postal_code')->nullable();
|
||||||
|
$table->string('account_number')->nullable();
|
||||||
|
$table->string('phone_number')->nullable();
|
||||||
|
$table->string('province_id')->nullable();
|
||||||
|
$table->string('province_name')->nullable();
|
||||||
|
$table->string('city_id')->nullable();
|
||||||
|
$table->string('city_name')->nullable();
|
||||||
|
|
||||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
$table->timestamps();
|
||||||
$table->string('email')->primary();
|
|
||||||
$table->string('token');
|
|
||||||
$table->timestamp('created_at')->nullable();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::create('sessions', function (Blueprint $table) {
|
Schema::create('sessions', function (Blueprint $table) {
|
||||||
@@ -43,7 +48,6 @@ return new class extends Migration
|
|||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('users');
|
Schema::dropIfExists('users');
|
||||||
Schema::dropIfExists('password_reset_tokens');
|
|
||||||
Schema::dropIfExists('sessions');
|
Schema::dropIfExists('sessions');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?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('oauth_auth_codes', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->index();
|
||||||
|
$table->foreignUuid('client_id');
|
||||||
|
$table->text('scopes')->nullable();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_auth_codes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?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('oauth_access_tokens', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->foreignUuid('client_id');
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->text('scopes')->nullable();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_access_tokens');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?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('oauth_refresh_tokens', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->char('access_token_id', 80)->index();
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_refresh_tokens');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?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('oauth_clients', function (Blueprint $table) {
|
||||||
|
$table->uuid('id')->primary();
|
||||||
|
$table->nullableMorphs('owner');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('secret')->nullable();
|
||||||
|
$table->string('provider')->nullable();
|
||||||
|
$table->text('redirect_uris');
|
||||||
|
$table->text('grant_types');
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_clients');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?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('oauth_device_codes', function (Blueprint $table) {
|
||||||
|
$table->char('id', 80)->primary();
|
||||||
|
$table->foreignId('user_id')->nullable()->index();
|
||||||
|
$table->foreignUuid('client_id')->index();
|
||||||
|
$table->char('user_code', 8)->unique();
|
||||||
|
$table->text('scopes');
|
||||||
|
$table->boolean('revoked');
|
||||||
|
$table->dateTime('user_approved_at')->nullable();
|
||||||
|
$table->dateTime('last_polled_at')->nullable();
|
||||||
|
$table->dateTime('expires_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('oauth_device_codes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the migration connection name.
|
||||||
|
*/
|
||||||
|
public function getConnection(): ?string
|
||||||
|
{
|
||||||
|
return $this->connection ?? config('passport.connection');
|
||||||
|
}
|
||||||
|
};
|
||||||
3
backend/database/seeders/DatabaseSeeder.php
Normal file → Executable file
3
backend/database/seeders/DatabaseSeeder.php
Normal file → Executable file
@@ -18,8 +18,9 @@ class DatabaseSeeder extends Seeder
|
|||||||
// User::factory(10)->create();
|
// User::factory(10)->create();
|
||||||
|
|
||||||
User::factory()->create([
|
User::factory()->create([
|
||||||
'name' => 'Test User',
|
'username' => 'Test User',
|
||||||
'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
|
'password' => 'password123@',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
backend/resources/lang/ar/notifications.php
Normal file
45
backend/resources/lang/ar/notifications.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'exception_message' => 'رسالة استثناء: :message',
|
||||||
|
'exception_trace' => 'تتبع الإستثناء: :trace',
|
||||||
|
'exception_message_title' => 'رسالة استثناء',
|
||||||
|
'exception_trace_title' => 'تتبع الإستثناء',
|
||||||
|
|
||||||
|
'backup_failed_subject' => 'أخفق النسخ الاحتياطي لل :application_name',
|
||||||
|
'backup_failed_body' => 'مهم: حدث خطأ أثناء النسخ الاحتياطي :application_name',
|
||||||
|
|
||||||
|
'backup_successful_subject' => 'نسخ احتياطي جديد ناجح ل :application_name',
|
||||||
|
'backup_successful_subject_title' => 'نجاح النسخ الاحتياطي الجديد!',
|
||||||
|
'backup_successful_body' => 'أخبار عظيمة، نسخة احتياطية جديدة ل :application_name تم إنشاؤها بنجاح على القرص المسمى :disk_name.',
|
||||||
|
|
||||||
|
'cleanup_failed_subject' => 'فشل تنظيف النسخ الاحتياطي للتطبيق :application_name .',
|
||||||
|
'cleanup_failed_body' => 'حدث خطأ أثناء تنظيف النسخ الاحتياطية ل :application_name',
|
||||||
|
|
||||||
|
'cleanup_successful_subject' => 'تنظيف النسخ الاحتياطية ل :application_name تمت بنجاح',
|
||||||
|
'cleanup_successful_subject_title' => 'تنظيف النسخ الاحتياطية تم بنجاح!',
|
||||||
|
'cleanup_successful_body' => 'تنظيف النسخ الاحتياطية ل :application_name على القرص المسمى :disk_name تم بنجاح.',
|
||||||
|
|
||||||
|
'healthy_backup_found_subject' => 'النسخ الاحتياطية ل :application_name على القرص :disk_name صحية',
|
||||||
|
'healthy_backup_found_subject_title' => 'النسخ الاحتياطية ل :application_name صحية',
|
||||||
|
'healthy_backup_found_body' => 'تعتبر النسخ الاحتياطية ل :application_name صحية. عمل جيد!',
|
||||||
|
|
||||||
|
'unhealthy_backup_found_subject' => 'مهم: النسخ الاحتياطية ل :application_name غير صحية',
|
||||||
|
'unhealthy_backup_found_subject_title' => 'مهم: النسخ الاحتياطية ل :application_name غير صحية. :problem',
|
||||||
|
'unhealthy_backup_found_body' => 'النسخ الاحتياطية ل :application_name على القرص :disk_name غير صحية.',
|
||||||
|
'unhealthy_backup_found_not_reachable' => 'لا يمكن الوصول إلى وجهة النسخ الاحتياطي. :error',
|
||||||
|
'unhealthy_backup_found_empty' => 'لا توجد نسخ احتياطية لهذا التطبيق على الإطلاق.',
|
||||||
|
'unhealthy_backup_found_old' => 'تم إنشاء أحدث النسخ الاحتياطية في :date وتعتبر قديمة جدا.',
|
||||||
|
'unhealthy_backup_found_unknown' => 'عذرا، لا يمكن تحديد سبب دقيق.',
|
||||||
|
'unhealthy_backup_found_full' => 'النسخ الاحتياطية تستخدم الكثير من التخزين. الاستخدام الحالي هو :disk_usage وهو أعلى من الحد المسموح به من :disk_limit.',
|
||||||
|
|
||||||
|
'no_backups_info' => 'لم يتم عمل نسخ احتياطية حتى الآن',
|
||||||
|
'application_name' => 'اسم التطبيق',
|
||||||
|
'backup_name' => 'اسم النسخ الاحتياطي',
|
||||||
|
'disk' => 'القرص',
|
||||||
|
'newest_backup_size' => 'أحدث حجم للنسخ الاحتياطي',
|
||||||
|
'number_of_backups' => 'عدد النسخ الاحتياطية',
|
||||||
|
'total_storage_used' => 'إجمالي مساحة التخزين المستخدمة',
|
||||||
|
'newest_backup_date' => 'أحدث تاريخ النسخ الاحتياطي',
|
||||||
|
'oldest_backup_date' => 'أقدم تاريخ نسخ احتياطي',
|
||||||
|
];
|
||||||
20
backend/resources/lang/en/auth.php
Normal file
20
backend/resources/lang/en/auth.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used during authentication for various
|
||||||
|
| messages that we need to display to the user. You are free to modify
|
||||||
|
| these language lines according to your application's requirements.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => 'These credentials do not match our records.',
|
||||||
|
'password' => 'The provided password is incorrect.',
|
||||||
|
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
|
||||||
|
|
||||||
|
];
|
||||||
11
backend/resources/lang/en/messages.php
Normal file
11
backend/resources/lang/en/messages.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'successful' => 'The operation was successful.',
|
||||||
|
'invalid_credential' => 'Provided credential is invalid.',
|
||||||
|
'incorrect_current_password' => 'Current password is incorrect.',
|
||||||
|
'new_password_email_sent' => 'Your new password sent to your email',
|
||||||
|
'file_upload_failed' => 'The file can not be uploaded.',
|
||||||
|
'otp' => 'your otp token is : ',
|
||||||
|
'incorrect_otp' => 'Incorrect OTP code.',
|
||||||
|
];
|
||||||
19
backend/resources/lang/en/pagination.php
Normal file
19
backend/resources/lang/en/pagination.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pagination Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used by the paginator library to build
|
||||||
|
| the simple pagination links. You are free to change them to anything
|
||||||
|
| you want to customize your views to better match your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'previous' => '« Previous',
|
||||||
|
'next' => 'Next »',
|
||||||
|
|
||||||
|
];
|
||||||
22
backend/resources/lang/en/passwords.php
Normal file
22
backend/resources/lang/en/passwords.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are the default lines which match reasons
|
||||||
|
| that are given by the password broker for a password update attempt
|
||||||
|
| has failed, such as for an invalid token or invalid new password.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'reset' => 'Your password has been reset.',
|
||||||
|
'sent' => 'We have emailed your password reset link.',
|
||||||
|
'throttled' => 'Please wait before retrying.',
|
||||||
|
'token' => 'This password reset token is invalid.',
|
||||||
|
'user' => "We can't find a user with that email address.",
|
||||||
|
|
||||||
|
];
|
||||||
186
backend/resources/lang/en/validation.php
Normal file
186
backend/resources/lang/en/validation.php
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Validation Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines contain the default error messages used by
|
||||||
|
| the validator class. Some of these rules have multiple versions such
|
||||||
|
| as the size rules. Feel free to tweak each of these messages here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'accepted' => 'The :attribute field must be accepted.',
|
||||||
|
'accepted_if' => 'The :attribute field must be accepted when :other is :value.',
|
||||||
|
'active_url' => 'The :attribute field must be a valid URL.',
|
||||||
|
'after' => 'The :attribute field must be a date after :date.',
|
||||||
|
'after_or_equal' => 'The :attribute field must be a date after or equal to :date.',
|
||||||
|
'alpha' => 'The :attribute field must only contain letters.',
|
||||||
|
'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.',
|
||||||
|
'alpha_num' => 'The :attribute field must only contain letters and numbers.',
|
||||||
|
'array' => 'The :attribute field must be an array.',
|
||||||
|
'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.',
|
||||||
|
'before' => 'The :attribute field must be a date before :date.',
|
||||||
|
'before_or_equal' => 'The :attribute field must be a date before or equal to :date.',
|
||||||
|
'between' => [
|
||||||
|
'array' => 'The :attribute field must have between :min and :max items.',
|
||||||
|
'file' => 'The :attribute field must be between :min and :max kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be between :min and :max.',
|
||||||
|
'string' => 'The :attribute field must be between :min and :max characters.',
|
||||||
|
],
|
||||||
|
'boolean' => 'The :attribute field must be true or false.',
|
||||||
|
'confirmed' => 'The :attribute field confirmation does not match.',
|
||||||
|
'current_password' => 'The password is incorrect.',
|
||||||
|
'date' => 'The :attribute field must be a valid date.',
|
||||||
|
'date_equals' => 'The :attribute field must be a date equal to :date.',
|
||||||
|
'date_format' => 'The :attribute field must match the format :format.',
|
||||||
|
'decimal' => 'The :attribute field must have :decimal decimal places.',
|
||||||
|
'declined' => 'The :attribute field must be declined.',
|
||||||
|
'declined_if' => 'The :attribute field must be declined when :other is :value.',
|
||||||
|
'different' => 'The :attribute field and :other must be different.',
|
||||||
|
'digits' => 'The :attribute field must be :digits digits.',
|
||||||
|
'digits_between' => 'The :attribute field must be between :min and :max digits.',
|
||||||
|
'dimensions' => 'The :attribute field has invalid image dimensions.',
|
||||||
|
'distinct' => 'The :attribute field has a duplicate value.',
|
||||||
|
'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.',
|
||||||
|
'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.',
|
||||||
|
'email' => 'The :attribute field must be a valid email address.',
|
||||||
|
'ends_with' => 'The :attribute field must end with one of the following: :values.',
|
||||||
|
'enum' => 'The selected :attribute is invalid.',
|
||||||
|
'exists' => 'The selected :attribute is invalid.',
|
||||||
|
'file' => 'The :attribute field must be a file.',
|
||||||
|
'filled' => 'The :attribute field must have a value.',
|
||||||
|
'gt' => [
|
||||||
|
'array' => 'The :attribute field must have more than :value items.',
|
||||||
|
'file' => 'The :attribute field must be greater than :value kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be greater than :value.',
|
||||||
|
'string' => 'The :attribute field must be greater than :value characters.',
|
||||||
|
],
|
||||||
|
'gte' => [
|
||||||
|
'array' => 'The :attribute field must have :value items or more.',
|
||||||
|
'file' => 'The :attribute field must be greater than or equal to :value kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be greater than or equal to :value.',
|
||||||
|
'string' => 'The :attribute field must be greater than or equal to :value characters.',
|
||||||
|
],
|
||||||
|
'image' => 'The :attribute field must be an image.',
|
||||||
|
'in' => 'The selected :attribute is invalid.',
|
||||||
|
'in_array' => 'The :attribute field must exist in :other.',
|
||||||
|
'integer' => 'The :attribute field must be an integer.',
|
||||||
|
'ip' => 'The :attribute field must be a valid IP address.',
|
||||||
|
'ipv4' => 'The :attribute field must be a valid IPv4 address.',
|
||||||
|
'ipv6' => 'The :attribute field must be a valid IPv6 address.',
|
||||||
|
'json' => 'The :attribute field must be a valid JSON string.',
|
||||||
|
'lowercase' => 'The :attribute field must be lowercase.',
|
||||||
|
'lt' => [
|
||||||
|
'array' => 'The :attribute field must have less than :value items.',
|
||||||
|
'file' => 'The :attribute field must be less than :value kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be less than :value.',
|
||||||
|
'string' => 'The :attribute field must be less than :value characters.',
|
||||||
|
],
|
||||||
|
'lte' => [
|
||||||
|
'array' => 'The :attribute field must not have more than :value items.',
|
||||||
|
'file' => 'The :attribute field must be less than or equal to :value kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be less than or equal to :value.',
|
||||||
|
'string' => 'The :attribute field must be less than or equal to :value characters.',
|
||||||
|
],
|
||||||
|
'mac_address' => 'The :attribute field must be a valid MAC address.',
|
||||||
|
'max' => [
|
||||||
|
'array' => 'The :attribute field must not have more than :max items.',
|
||||||
|
'file' => 'The :attribute field must not be greater than :max kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must not be greater than :max.',
|
||||||
|
'string' => 'The :attribute field must not be greater than :max characters.',
|
||||||
|
],
|
||||||
|
'max_digits' => 'The :attribute field must not have more than :max digits.',
|
||||||
|
'mimes' => 'The :attribute field must be a file of type: :values.',
|
||||||
|
'mimetypes' => 'The :attribute field must be a file of type: :values.',
|
||||||
|
'min' => [
|
||||||
|
'array' => 'The :attribute field must have at least :min items.',
|
||||||
|
'file' => 'The :attribute field must be at least :min kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be at least :min.',
|
||||||
|
'string' => 'The :attribute field must be at least :min characters.',
|
||||||
|
],
|
||||||
|
'min_digits' => 'The :attribute field must have at least :min digits.',
|
||||||
|
'missing' => 'The :attribute field must be missing.',
|
||||||
|
'missing_if' => 'The :attribute field must be missing when :other is :value.',
|
||||||
|
'missing_unless' => 'The :attribute field must be missing unless :other is :value.',
|
||||||
|
'missing_with' => 'The :attribute field must be missing when :values is present.',
|
||||||
|
'missing_with_all' => 'The :attribute field must be missing when :values are present.',
|
||||||
|
'multiple_of' => 'The :attribute field must be a multiple of :value.',
|
||||||
|
'not_in' => 'The selected :attribute is invalid.',
|
||||||
|
'not_regex' => 'The :attribute field format is invalid.',
|
||||||
|
'numeric' => 'The :attribute field must be a number.',
|
||||||
|
'password' => [
|
||||||
|
'letters' => 'The :attribute field must contain at least one letter.',
|
||||||
|
'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.',
|
||||||
|
'numbers' => 'The :attribute field must contain at least one number.',
|
||||||
|
'symbols' => 'The :attribute field must contain at least one symbol.',
|
||||||
|
'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.',
|
||||||
|
],
|
||||||
|
'present' => 'The :attribute field must be present.',
|
||||||
|
'prohibited' => 'The :attribute field is prohibited.',
|
||||||
|
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
|
||||||
|
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',
|
||||||
|
'prohibits' => 'The :attribute field prohibits :other from being present.',
|
||||||
|
'regex' => 'The :attribute field format is invalid.',
|
||||||
|
'required' => 'The :attribute field is required.',
|
||||||
|
'required_array_keys' => 'The :attribute field must contain entries for: :values.',
|
||||||
|
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||||
|
'required_if_accepted' => 'The :attribute field is required when :other is accepted.',
|
||||||
|
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||||
|
'required_with' => 'The :attribute field is required when :values is present.',
|
||||||
|
'required_with_all' => 'The :attribute field is required when :values are present.',
|
||||||
|
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||||
|
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||||
|
'same' => 'The :attribute field must match :other.',
|
||||||
|
'size' => [
|
||||||
|
'array' => 'The :attribute field must contain :size items.',
|
||||||
|
'file' => 'The :attribute field must be :size kilobytes.',
|
||||||
|
'numeric' => 'The :attribute field must be :size.',
|
||||||
|
'string' => 'The :attribute field must be :size characters.',
|
||||||
|
],
|
||||||
|
'starts_with' => 'The :attribute field must start with one of the following: :values.',
|
||||||
|
'string' => 'The :attribute field must be a string.',
|
||||||
|
'timezone' => 'The :attribute field must be a valid timezone.',
|
||||||
|
'unique' => 'The :attribute has already been taken.',
|
||||||
|
'uploaded' => 'The :attribute failed to upload.',
|
||||||
|
'uppercase' => 'The :attribute field must be uppercase.',
|
||||||
|
'url' => 'The :attribute field must be a valid URL.',
|
||||||
|
'ulid' => 'The :attribute field must be a valid ULID.',
|
||||||
|
'uuid' => 'The :attribute field must be a valid UUID.',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Validation Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify custom validation messages for attributes using the
|
||||||
|
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||||
|
| specify a specific custom language line for a given attribute rule.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'custom' => [
|
||||||
|
'attribute-name' => [
|
||||||
|
'rule-name' => 'custom-message',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Validation Attributes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used to swap our attribute placeholder
|
||||||
|
| with something more reader friendly such as "E-Mail Address" instead
|
||||||
|
| of "email". This simply helps us make our message more expressive.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'attributes' => [
|
||||||
|
'phone_number' => 'phone number',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
20
backend/resources/lang/fa/auth.php
Normal file
20
backend/resources/lang/fa/auth.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used during authentication for various
|
||||||
|
| messages that we need to display to the user. You are free to modify
|
||||||
|
| these language lines according to your application's requirements.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => 'اطلاعات وارد شده صحیح نمی باشد',
|
||||||
|
'password' => 'رمزعبور صحیح نیست',
|
||||||
|
'throttle' => 'درخواست بیش از حد مجاز! لطفا بعد از :seconds ثانیه دوباره امتحان کنید',
|
||||||
|
|
||||||
|
];
|
||||||
11
backend/resources/lang/fa/messages.php
Normal file
11
backend/resources/lang/fa/messages.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'successful' => 'عملیات با موفقیت انجام شد.',
|
||||||
|
'invalid_credential' => 'نام کاربری یا رمز عبور اشتباه است',
|
||||||
|
'incorrect_current_password' => 'رمز عبور فعلی اشتباه است',
|
||||||
|
'new_password_email_sent' => 'رمز عبور جدید به ایمیل شما ارسال شد.',
|
||||||
|
'file_upload_failed' => 'بارگذاری فایل با خطا مواجه شد.',
|
||||||
|
'otp' => 'کد ورود شما : ',
|
||||||
|
'incorrect_otp' => 'کد تایید اشتباه است .',
|
||||||
|
];
|
||||||
19
backend/resources/lang/fa/pagination.php
Normal file
19
backend/resources/lang/fa/pagination.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Pagination Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used by the paginator library to build
|
||||||
|
| the simple pagination links. You are free to change them to anything
|
||||||
|
| you want to customize your views to better match your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'previous' => '« قبلی',
|
||||||
|
'next' => 'بعدی »',
|
||||||
|
|
||||||
|
];
|
||||||
22
backend/resources/lang/fa/passwords.php
Normal file
22
backend/resources/lang/fa/passwords.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are the default lines which match reasons
|
||||||
|
| that are given by the password broker for a password update attempt
|
||||||
|
| has failed, such as for an invalid token or invalid new password.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'reset' => 'رمز عبور شما با موفقیت بازیابی شد',
|
||||||
|
'sent' => 'ایمیلی جهت بازیابی رمزعبور برای شما ارسال شد',
|
||||||
|
'throttled' => 'لطفا اندکی صبر کنید و دوباره امتحان کنید',
|
||||||
|
'token' => 'مشخصه بازیابی رمزعبور شما صحیح نمی باشد',
|
||||||
|
'user' => "کاربری با این اطلاعات وجود ندارد",
|
||||||
|
|
||||||
|
];
|
||||||
192
backend/resources/lang/fa/validation.php
Normal file
192
backend/resources/lang/fa/validation.php
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Validation Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines contain the default error messages used by
|
||||||
|
| the validator class. Some of these rules have multiple versions such
|
||||||
|
| as the size rules. Feel free to tweak each of these messages here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'accepted' => 'گزینه :attribute باید تایید شود',
|
||||||
|
'accepted_if' => 'زمانی که گزینه :other برابر :value است :attribute باید تایید شود',
|
||||||
|
'active_url' => 'گزینه :attribute یک آدرس سایت معتبر نیست',
|
||||||
|
'after' => 'گزینه :attribute باید تاریخی بعد از :date باشد',
|
||||||
|
'after_or_equal' => 'گزینه :attribute باید تاریخی مساوی یا بعد از :date باشد',
|
||||||
|
'alpha' => 'گزینه :attribute باید تنها شامل حروف باشد',
|
||||||
|
'alpha_dash' => 'گزینه :attribute باید تنها شامل حروف، اعداد، خط تیره و زیر خط باشد',
|
||||||
|
'alpha_num' => 'گزینه :attribute باید تنها شامل حروف و اعداد باشد',
|
||||||
|
'array' => 'گزینه :attribute باید آرایه باشد',
|
||||||
|
'ascii' => 'گزینه :attribute تنها میتواند شامل تک حرف، عدد یا نماد ها باشد. .',
|
||||||
|
'before' => 'گزینه :attribute باید تاریخی قبل از :date باشد',
|
||||||
|
'before_or_equal' => 'گزینه :attribute باید تاریخی مساوی یا قبل از :date باشد',
|
||||||
|
'between' => [
|
||||||
|
'array' => 'گزینه :attribute باید بین :min و :max آیتم باشد',
|
||||||
|
'file' => 'گزینه :attribute باید بین :min و :max کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید بین :min و :max باشد',
|
||||||
|
'string' => 'گزینه :attribute باید بین :min و :max کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'boolean' => 'گزینه :attribute تنها می تواند صحیح یا غلط باشد',
|
||||||
|
'confirmed' => 'تایید مجدد گزینه :attribute صحیح نمی باشد',
|
||||||
|
'current_password' => 'رمزعبور صحیح نمی باشد',
|
||||||
|
'date' => 'گزینه :attribute یک تاریخ صحیح نمی باشد',
|
||||||
|
'date_equals' => 'گزینه :attribute باید تاریخی مساوی با :date باشد',
|
||||||
|
'date_format' => 'گزینه :attribute با فرمت :format همخوانی ندارد',
|
||||||
|
'decimal' => 'گزینه :attribute باید :decimal رقم اعشار داشته باشد.',
|
||||||
|
'declined' => 'گزینه :attribute باید رد شود',
|
||||||
|
'declined_if' => 'گزینه :attribute زمانی که :other برابر :value است باید رد شود',
|
||||||
|
'different' => 'گزینه :attribute و :other باید متفاوت باشند',
|
||||||
|
'digits' => 'گزینه :attribute باید :digits عدد باشد',
|
||||||
|
'digits_between' => 'گزینه :attribute باید بین :min و :max عدد باشد',
|
||||||
|
'dimensions' => 'ابعاد تصویر گزینه :attribute مجاز نمی باشد',
|
||||||
|
'distinct' => 'گزینه :attribute دارای افزونگی داده می باشد',
|
||||||
|
'doesnt_end_with' => 'گزینه :attribute نباید با این مقادیر به پایان برسد: :values.',
|
||||||
|
'doesnt_start_with' => 'گزینه :attribute نباید با این مقادیر شروع شود: :values.',
|
||||||
|
'email' => 'گزینه :attribute باید یک آدرس ایمیل صحیح باشد',
|
||||||
|
'ends_with' => 'گزینه :attribute باید با یکی از این مقادیر پایان یابد، :values',
|
||||||
|
'enum' => 'گزینه :attribute صحیح نمی باشد',
|
||||||
|
'exists' => 'گزینه انتخاب شده :attribute صحیح نمی باشد',
|
||||||
|
'file' => 'گزینه :attribute باید یک فایل باشد',
|
||||||
|
'filled' => 'گزینه :attribute نمی تواند خالی باشد',
|
||||||
|
'gt' => [
|
||||||
|
'array' => 'گزینه :attribute باید بیشتر از :value آیتم باشد',
|
||||||
|
'file' => 'گزینه :attribute باید بزرگتر از :value کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید بزرگتر از :value باشد',
|
||||||
|
'string' => 'گزینه :attribute باید بزرگتر از :value کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'gte' => [
|
||||||
|
'array' => 'گزینه :attribute باید :value آیتم یا بیشتر داشته باشد',
|
||||||
|
'file' => 'گزینه :attribute باید بزرگتر یا مساوی :value کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید بزرگتر یا مساوی :value باشد',
|
||||||
|
'string' => 'گزینه :attribute باید بزرگتر یا مساوی :value کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'image' => 'گزینه :attribute باید از نوع تصویر باشد',
|
||||||
|
'in' => 'گزینه انتخابی :attribute صحیح نمی باشد',
|
||||||
|
'in_array' => 'گزینه :attribute در :other وجود ندارد',
|
||||||
|
'integer' => 'گزینه :attribute باید از نوع عددی باشد',
|
||||||
|
'ip' => 'گزینه :attribute باید آی پی آدرس باشد',
|
||||||
|
'ipv4' => 'گزینه :attribute باید آی پی آدرس ورژن 4 باشد',
|
||||||
|
'ipv6' => 'گزینه :attribute باید آی پی آدرس ورژن 6 باشد',
|
||||||
|
'json' => 'گزینه :attribute باید از نوع رشته جیسون باشد',
|
||||||
|
'lowercase' => 'گزینه :attribute باید با حروف کوچک باشد.',
|
||||||
|
'lt' => [
|
||||||
|
'array' => 'گزینه :attribute باید کمتر از :value آیتم داشته باشد',
|
||||||
|
'file' => 'گزینه :attribute باید کمتر از :value کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید کمتر از :value باشد',
|
||||||
|
'string' => 'گزینه :attribute باید کمتر از :value کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'lte' => [
|
||||||
|
'array' => 'گزینه :attribute نباید کمتر از :value آیتم داشته باشد',
|
||||||
|
'file' => 'گزینه :attribute باید مساوی یا کمتر از :value کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید مساوی یا کمتر از :value باشد',
|
||||||
|
'string' => 'گزینه :attribute باید مساوی یا کمتر از :value کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'mac_address' => 'گزینه :attribute باید یک مک آدرس معتبر باشد',
|
||||||
|
'max' => [
|
||||||
|
'array' => 'گزینه :attribute نباید بیشتر از :max آیتم داشته باشد',
|
||||||
|
'file' => 'گزینه :attribute نباید بزرگتر از :max کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute نباید بزرگتر از :max باشد',
|
||||||
|
'string' => 'گزینه :attribute نباید بزرگتر از :max کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'max_digits' => 'گزینه :attribute نباید بیشتر از :max رقم باشد',
|
||||||
|
'mimes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
||||||
|
'mimetypes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
||||||
|
'min' => [
|
||||||
|
'array' => 'گزینه :attribute باید حداقل :min آیتم داشته باشد',
|
||||||
|
'file' => 'گزینه :attribute باید حداقل :min کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید حداقل :min باشد',
|
||||||
|
'string' => 'گزینه :attribute باید حداقل :min کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'min_digits' => 'گزینه :attribute باید حداقل :min رقم باشد',
|
||||||
|
'missing' => 'گزینه :attribute نباید تعریف شود.',
|
||||||
|
'missing_if' => 'گزینه :attribute زمانی که مقدار :other برابر :value می باشد، نباید تعریف شود',
|
||||||
|
'missing_unless' => 'گزینه :attribute نباید تعریف شود مگر اینکه گزینه :other برابر :value باشد',
|
||||||
|
'missing_with' => 'گزینه :attribute زمانی که مقدار :values تعریف شده است دیگر نباید تعریف شود.',
|
||||||
|
'missing_with_all' => 'گزینه :attribute زمانی که :values مقدار دارد دیگر نباید تعریف شود.',
|
||||||
|
'multiple_of' => 'گزینه :attribute باید حاصل ضرب :value باشد',
|
||||||
|
'not_in' => 'گزینه انتخابی :attribute صحیح نمی باشد',
|
||||||
|
'not_regex' => 'فرمت گزینه :attribute صحیح نمی باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید از نوع عددی باشد',
|
||||||
|
'password' => [
|
||||||
|
'letters' => 'گزینه :attribute باید حداقل شامل یک حرف باشد',
|
||||||
|
'mixed' => 'گزینه :attribute باید شامل حداقل یک حرف بزرگ و یک حرف کوچک باشد',
|
||||||
|
'numbers' => 'گزینه :attribute باید شامل حداقل یک عدد باشد',
|
||||||
|
'symbols' => 'گزینه :attribute باید شامل حداقل یک کارکتر خاص باشد',
|
||||||
|
'uncompromised' => 'محتوای وارده شده در :attribute ایمن نمی باشد. لطفا گزینه :attribute را اصلاح فرمایید',
|
||||||
|
],
|
||||||
|
'present' => 'گزینه :attribute باید از نوع درصد باشد',
|
||||||
|
'prohibited' => 'گزینه :attribute مجاز نمی باشد',
|
||||||
|
'prohibited_if' => 'گزینه :attribute زمانی که :other برابر :value باشد مجاز نمی باشد',
|
||||||
|
'prohibited_unless' => 'گزینه :attribute مجاز نیست مگر :other برابر :values باشد',
|
||||||
|
'prohibits' => 'گزینه :attribute باعث ممنوعیت :other می باشد',
|
||||||
|
'regex' => 'فرمت گزینه :attribute صحیح نمی باشد',
|
||||||
|
'required' => 'تکمیل گزینه :attribute الزامی است',
|
||||||
|
'required_array_keys' => 'گزینه :attribute باید شامل مقادیر: :values باشد',
|
||||||
|
'required_if' => 'تکمیل گزینه :attribute زمانی که :other دارای مقدار :value است الزامی می باشد',
|
||||||
|
'required_if_accepted' => 'تکمیل گزینه :attribute زمانی که :other انتخاب شده الزامی است',
|
||||||
|
'required_unless' => 'تکمیل گزینه :attribute الزامی می باشد مگر :other دارای مقدار :values باشد',
|
||||||
|
'required_with' => 'تکمیل گزینه :attribute زمانی که مقدار :values درصد است الزامی است',
|
||||||
|
'required_with_all' => 'تکمیل گزینه :attribute زمانی که مقادیر :values درصد است الزامی می باشد',
|
||||||
|
'required_without' => 'تکمیل گزینه :attribute زمانی که مقدار :values درصد نیست الزامی است',
|
||||||
|
'required_without_all' => 'تکمیل گزینه :attribute زمانی که هیچ کدام از مقادیر :values درصد نیست الزامی است',
|
||||||
|
'same' => 'گزینه های :attribute و :other باید یکی باشند',
|
||||||
|
'size' => [
|
||||||
|
'array' => 'گزینه :attribute باید شامل :size آیتم باشد',
|
||||||
|
'file' => 'گزینه :attribute باید :size کیلوبایت باشد',
|
||||||
|
'numeric' => 'گزینه :attribute باید :size باشد',
|
||||||
|
'string' => 'گزینه :attribute باید :size کاراکتر باشد',
|
||||||
|
],
|
||||||
|
'starts_with' => 'گزینه :attribute باید با یکی از این مقادیر شروع شود، :values',
|
||||||
|
'string' => 'گزینه :attribute باید تنها شامل حروف باشد',
|
||||||
|
'timezone' => 'گزینه :attribute باید از نوع منطقه زمانی صحیح باشد',
|
||||||
|
'unique' => 'این :attribute از قبل ثبت شده است',
|
||||||
|
'uploaded' => 'بارگذاری گزینه :attribute شکست خورد',
|
||||||
|
'uppercase' => 'گزینه :attribute باید با حروف بزرگ باشد',
|
||||||
|
'url' => 'فرمت :attribute اشتباه است',
|
||||||
|
'ulid' => 'گزینه :attribute باید یک ULID صحیح باشد.',
|
||||||
|
'uuid' => 'گزینه :attribute باید یک UUID صحیح باشد',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Validation Language Lines
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify custom validation messages for attributes using the
|
||||||
|
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||||
|
| specify a specific custom language line for a given attribute rule.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'custom' => [
|
||||||
|
'attribute-name' => [
|
||||||
|
'rule-name' => 'custom-message',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Validation Attributes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following language lines are used to swap our attribute placeholder
|
||||||
|
| with something more reader friendly such as "E-Mail Address" instead
|
||||||
|
| of "email". This simply helps us make our message more expressive.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'attributes' => [
|
||||||
|
'name' => 'نام',
|
||||||
|
'username' => 'نام کاربری',
|
||||||
|
'email' => 'ایمیل',
|
||||||
|
'first_name' => 'نام',
|
||||||
|
'last_name' => 'نام خانوادگی',
|
||||||
|
'password' => 'رمز عبور',
|
||||||
|
'password_confirmation' => 'تاییدیه رمز عبور',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
24
backend/resources/views/emails/login-notification.blade.php
Normal file
24
backend/resources/views/emails/login-notification.blade.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Login Notification</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Hello {{ $user->username }}</h2>
|
||||||
|
|
||||||
|
<p>You have successfully logged in to your account.</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Email: {{ $user->email }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If this login was not done by you, please contact support immediately.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p>Thank you.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
backend/routes/api.php
Executable file
10
backend/routes/api.php
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\User\Controller\Auth\AuthController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::get('/user', function (Request $request) {
|
||||||
|
return $request->user();
|
||||||
|
})->middleware('auth:api');
|
||||||
|
|
||||||
23
backend/routes/web.php
Normal file → Executable file
23
backend/routes/web.php
Normal file → Executable file
@@ -1,7 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\User\Controller\Auth\AuthController;
|
||||||
|
use App\User\Controller\ProfileController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::prefix('auth')
|
||||||
return view('welcome');
|
->name('Auth.')
|
||||||
});
|
->controller(AuthController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::post('register', 'register')->name('register');
|
||||||
|
Route::post('login', 'login')->name('login');
|
||||||
|
Route::post('logout', 'logout')->name('logout');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('profile')
|
||||||
|
->name('profile.')
|
||||||
|
->middleware('auth')
|
||||||
|
->controller(ProfileController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('info', 'info')->name('info');
|
||||||
|
Route::post('edit', 'edit')->name('edit');
|
||||||
|
Route::post('change_password', 'changePassword')->name('changePassword');
|
||||||
|
});
|
||||||
|
|||||||
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/private/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/app/public/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
0
backend/storage/logs/.gitignore
vendored
Normal file → Executable file
@@ -1,60 +0,0 @@
|
|||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
|
||||||
container_name: pgsql
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "8091:5432"
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
||||||
volumes:
|
|
||||||
- payment-db:/var/lib/postgresql/data
|
|
||||||
networks:
|
|
||||||
- payment
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: ${BACKEND_PATH}
|
|
||||||
dockerfile: Dockerfile.production
|
|
||||||
container_name: laravel
|
|
||||||
tty: true
|
|
||||||
restart: unless-stopped
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:80"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 3
|
|
||||||
ports:
|
|
||||||
- "8003:80"
|
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
|
||||||
depends_on:
|
|
||||||
- postgres
|
|
||||||
networks:
|
|
||||||
- payment
|
|
||||||
logging:
|
|
||||||
driver: "syslog"
|
|
||||||
options:
|
|
||||||
syslog-address: "tcp://host.docker.internal:514"
|
|
||||||
tag: "laravel-backend"
|
|
||||||
syslog-facility: "daemon"
|
|
||||||
max-size: "10m"
|
|
||||||
mem_limit: 512M
|
|
||||||
cpus: 1
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
payment-db:
|
|
||||||
driver: local
|
|
||||||
|
|
||||||
networks:
|
|
||||||
payment:
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,14 +1,39 @@
|
|||||||
services:
|
services:
|
||||||
postgres:
|
nginx:
|
||||||
image: docker.arvancloud.ir/postgres:17.8-alpine3.23
|
image: nginx:stable-alpine3.23-perl
|
||||||
container_name: pgsql
|
container_name: nginx
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8091:5432"
|
- "8000:80"
|
||||||
|
volumes:
|
||||||
|
- ./nginx/payment.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:8.6.0-alpine3.23
|
||||||
|
container_name: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
tty: true
|
||||||
|
networks:
|
||||||
|
- payment
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:18.2-alpine3.23
|
||||||
|
container_name: payment-db
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8092:5432"
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
POSTGRES_USER: ${POSTGRES_USER}
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
volumes:
|
volumes:
|
||||||
- payment-db:/var/lib/postgresql/data
|
- payment-db:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
@@ -22,17 +47,22 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8003:80"
|
- "9000:9000"
|
||||||
- "443:443"
|
|
||||||
- "443:443/udp"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
- ${BACKEND_PATH}:/var/www/${PROJECT_NAME}
|
||||||
# - caddy_data:/data
|
|
||||||
# - caddy_config:/config
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
- payment
|
- payment
|
||||||
|
# logging:
|
||||||
|
# driver: "syslog"
|
||||||
|
# options:
|
||||||
|
# syslog-address: "tcp://host.docker.internal:514"
|
||||||
|
# tag: "laravel-backend"
|
||||||
|
# syslog-facility: "daemon"
|
||||||
|
# max-size: "10m"
|
||||||
|
# mem_limit: 512M
|
||||||
|
# cpus: 1
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
payment-db:
|
payment-db:
|
||||||
|
|||||||
21
nginx/payment.conf
Normal file
21
nginx/payment.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
charset utf-8;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/index\.php(/|$) {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass laravel:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_hide_header X-Powered-By;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user