feat: add user enums and Persian validation messages
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum UserGender: int
|
||||||
|
{
|
||||||
|
case UNKNOWN =0;
|
||||||
|
case MALE =1;
|
||||||
|
case FEMALE =2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum UserMarital:int
|
||||||
|
{
|
||||||
|
case SINGLE =0;
|
||||||
|
case MARRIED =1;
|
||||||
|
case DIVORCED =2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum UserStatus: int
|
||||||
|
{
|
||||||
|
case DISABLE = 0;
|
||||||
|
case ENABLE = 1;
|
||||||
|
}
|
||||||
+28
-11
@@ -8,16 +8,19 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class User
|
* Class User
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $first_name
|
* @property string $first_name
|
||||||
* @property string $last_name
|
* @property string $last_name
|
||||||
* @property int $file_id
|
* @property int|null $file_id
|
||||||
|
* @property int|null $city_id
|
||||||
|
* @property int|null $province_id
|
||||||
* @property string $national_code
|
* @property string $national_code
|
||||||
* @property int $gender
|
* @property int $gender
|
||||||
* @property int $marital_status
|
* @property int $marital_status
|
||||||
@@ -26,19 +29,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property string $email
|
* @property string $email
|
||||||
* @property string $username
|
* @property string $username
|
||||||
* @property string $password
|
* @property string $password
|
||||||
* @property string|null $user_province
|
* @property bool $status
|
||||||
* @property int|null $user_city
|
|
||||||
* @property Carbon $created_at
|
* @property Carbon $created_at
|
||||||
* @property Carbon $updated_at
|
* @property Carbon $updated_at
|
||||||
* @property string|null $deleted_at
|
* @property string|null $deleted_at
|
||||||
*
|
*
|
||||||
* @property File $file
|
* @property File|null $file
|
||||||
|
* @property Province|null $province
|
||||||
|
* @property City|null $city
|
||||||
* @property Collection|Booking[] $bookings
|
* @property Collection|Booking[] $bookings
|
||||||
* @property Collection|Passenger[] $passengers
|
* @property Collection|Passenger[] $passengers
|
||||||
*
|
*
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
*/
|
*/
|
||||||
class User extends Model
|
class User extends Authenticate
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
@@ -46,9 +50,11 @@ class User extends Model
|
|||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'file_id' => 'int',
|
'file_id' => 'int',
|
||||||
|
'city_id' => 'int',
|
||||||
|
'province_id' => 'int',
|
||||||
'gender' => 'int',
|
'gender' => 'int',
|
||||||
'marital_status' => 'int',
|
'marital_status' => 'int',
|
||||||
'user_city' => 'int'
|
'status' => 'bool'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@@ -59,6 +65,8 @@ class User extends Model
|
|||||||
'first_name',
|
'first_name',
|
||||||
'last_name',
|
'last_name',
|
||||||
'file_id',
|
'file_id',
|
||||||
|
'city_id',
|
||||||
|
'province_id',
|
||||||
'national_code',
|
'national_code',
|
||||||
'gender',
|
'gender',
|
||||||
'marital_status',
|
'marital_status',
|
||||||
@@ -67,8 +75,7 @@ class User extends Model
|
|||||||
'email',
|
'email',
|
||||||
'username',
|
'username',
|
||||||
'password',
|
'password',
|
||||||
'user_province',
|
'status'
|
||||||
'user_city'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public function file()
|
public function file()
|
||||||
@@ -76,6 +83,16 @@ class User extends Model
|
|||||||
return $this->belongsTo(File::class);
|
return $this->belongsTo(File::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function province()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Province::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function city()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(City::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function bookings()
|
public function bookings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Booking::class);
|
return $this->hasMany(Booking::class);
|
||||||
|
|||||||
+10
-3
@@ -68,7 +68,7 @@ return [
|
|||||||
'string' => 'گزینه :attribute باید بزرگتر یا مساوی :value کاراکتر باشد',
|
'string' => 'گزینه :attribute باید بزرگتر یا مساوی :value کاراکتر باشد',
|
||||||
],
|
],
|
||||||
'image' => 'گزینه :attribute باید از نوع تصویر باشد',
|
'image' => 'گزینه :attribute باید از نوع تصویر باشد',
|
||||||
'hex_color'=>'فیلد :attribute باید یک رنگ هگزادسیمال معتبر باشد.',
|
'hex_color' => 'فیلد :attribute باید یک رنگ هگزادسیمال معتبر باشد.',
|
||||||
'in' => 'گزینه انتخابی :attribute صحیح نمی باشد',
|
'in' => 'گزینه انتخابی :attribute صحیح نمی باشد',
|
||||||
'in_array' => 'گزینه :attribute در :other وجود ندارد',
|
'in_array' => 'گزینه :attribute در :other وجود ندارد',
|
||||||
'integer' => 'گزینه :attribute باید از نوع عددی باشد',
|
'integer' => 'گزینه :attribute باید از نوع عددی باشد',
|
||||||
@@ -101,7 +101,7 @@ return [
|
|||||||
],
|
],
|
||||||
'max_digits' => 'گزینه :attribute نباید بیشتر از :max رقم باشد',
|
'max_digits' => 'گزینه :attribute نباید بیشتر از :max رقم باشد',
|
||||||
'mimes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
'mimes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
||||||
'mimetypes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
'mimetypes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values',
|
||||||
'min' => [
|
'min' => [
|
||||||
'array' => 'گزینه :attribute باید حداقل :min آیتم داشته باشد',
|
'array' => 'گزینه :attribute باید حداقل :min آیتم داشته باشد',
|
||||||
'file' => 'گزینه :attribute باید حداقل :min کیلوبایت باشد',
|
'file' => 'گزینه :attribute باید حداقل :min کیلوبایت باشد',
|
||||||
@@ -245,7 +245,14 @@ return [
|
|||||||
'value' => 'مقدار تنظیمات',
|
'value' => 'مقدار تنظیمات',
|
||||||
'message' => 'متن پیام',
|
'message' => 'متن پیام',
|
||||||
'question' => 'سوال',
|
'question' => 'سوال',
|
||||||
'answer' => 'جواب'
|
'answer' => 'جواب',
|
||||||
|
'spouse_name' => 'مشخصات همسر',
|
||||||
|
'marital_status' => 'وضعیت تاهل',
|
||||||
|
'avatar' => 'تصویر',
|
||||||
|
'province_id' => 'استان',
|
||||||
|
'city_id' => 'شهر',
|
||||||
|
'national_code' => 'کدملی'
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user