This commit is contained in:
mobin
2026-04-08 07:22:13 +00:00
parent 2adb741dac
commit a6b5f27343
30300 changed files with 134406 additions and 1504 deletions
+11 -6
View File
@@ -51,17 +51,22 @@ class Attendance extends Model
{
// dd($start,$end, $date);
$fakedate = '2020/02/20';
$start = Carbon::parse($start)->format('Y/m/d') ? Carbon::parse($start) : Carbon::parse($start . $fakedate);
$end = Carbon::parse($end)->format('Y/m/d') ? Carbon::parse($end) : Carbon::parse($end . $fakedate);
if (!str_contains($start, '-')) {
$start = $fakedate . $start;
}
if (!str_contains($end, '-')) {
$end = $fakedate . $end;
}
$diffInSeconds = $start->diffInSeconds($end); // فاصله به ثانیه
$start = \Carbon\Carbon::parse($start);
$end = \Carbon\Carbon::parse($end);
$diffInSeconds = $start->diffInSeconds($end);
$hours = floor($diffInSeconds / 3600);
$minutes = floor(($diffInSeconds % 3600) / 60);
$seconds = $diffInSeconds % 60;
$duration = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
return $duration;
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
}
// public function attendanceBreak()
// {
-1
View File
@@ -14,7 +14,6 @@ class AttendanceBreak extends Model
'duration',
];
// رابطه به حضور
public function attendance()
{
return $this->belongsTo(Attendance::class);
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Log extends Model
{
protected $table = 'log';
protected $fillable = [
'error',
'created_at',
'updated_at',
'user',
];}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Pivot_Tasks extends Model
{
protected $table = 'pivot_tasks';
public $timestamps = false;
protected $fillable = [
'task_id',
'started_at',
'ended_at',
'duration',
'user_id',
];
}
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
use HasFactory;
protected $table = 'settings';
protected $fillable = [
'key',
'title',
'value',
];
}
+17 -7
View File
@@ -2,8 +2,11 @@
namespace App\Models;
use Illuminate\Console\View\Components\Task;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Tasks extends Model
{
@@ -36,20 +39,27 @@ class Tasks extends Model
'created_by',
'updated_by',
'deleted_by',
'parent',
];
// رابطه many-to-many با users
public function users()
{
// return $this->belongsToMany(User::class, 'pivot_tasks', 'task_id', 'user_id');
return $this->belongsToMany(
User::class, // مدل مقصد
'pivot_tasks', // جدول واسط
'task_id', // ستون جدول واسط که به جدول tasks اشاره می‌کنه
'user_id', // ستون جدول واسط که به جدول users اشاره می‌کنه
'task_id', // ستون جدول tasks که ستون واسط بهش اشاره می‌کنه (local key)
'plain_id' // ستون جدول users که ستون واسط بهش اشاره می‌کنه (related key)
User::class,
'pivot_tasks',
'task_id',
'user_id',
'task_id',
'plain_id',
);
}
public function pivotTask()
{
return DB::table('pivot_tasks')
->where('task_id', $this->task_id);
}
}
+6 -3
View File
@@ -32,6 +32,8 @@ class User extends Authenticatable
'user_name',
'is_admin',
'plain_id',
'break',
'req_counts',
];
@@ -62,14 +64,14 @@ class User extends Authenticatable
'task_id', // ستون جدول واسط که به جدول tasks اشاره می‌کنه
'plain_id', // ستون جدول users که ستون جدول واسط بهش اشاره می‌کنه (local key)
'task_id' // ستون جدول tasks که ستون جدول واسط بهش اشاره می‌کنه (related key)
);
)->withPivot(['id', 'started_at','ended_at','duration',]);
}
public function attendances()
{
return $this->hasMany(Attendance::class, 'user_identity', 'user_name')
->select('id', 'user_identity', 'entered_at', 'exited_at', 'duration','requested')
->select('id', 'user_identity', 'entered_at', 'exited_at', 'duration','requested', 'distance', 'distance_exit')
->orderBy('entered_at', 'desc');
@@ -79,7 +81,8 @@ class User extends Authenticatable
return $this->hasManyThrough(AttendanceBreak::class,Attendance::class,'user_identity','attendance_id',
'user_name', // local key در users
'id' // local key در attendances
);
)->orderBy('entered_at', 'desc');
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Webauth extends Model
{
// نام جدول
protected $table = 'webauth';
// فیلدهای قابل تخصیص انبوه
protected $fillable = [
'customer_id',
'name',
'credential_id',
'public_key',
'sign_count',
'transports',
'last_used_at',
];
// تبدیل نوع داده‌ها
protected $casts = [
'transports' => 'array', // فرض بر این است که transports به صورت JSON ذخیره می‌شود
'last_used_at' => 'datetime',
];
/**
* تعریف رابطه: این کلید متعلق به یک کاربر است.
*/
public function customer()
{
return $this->belongsTo(User::class);
}
}