main
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Attendance extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'user_identity',
|
||||
'latitude',
|
||||
'longitude',
|
||||
'latitude_exit',
|
||||
'longitude_exit',
|
||||
'ip_exit',
|
||||
'latitude_office',
|
||||
'longitude_office',
|
||||
'distance',
|
||||
'ip_address',
|
||||
'entered_at',
|
||||
'exited_at',
|
||||
];
|
||||
|
||||
public function setEntryLocationAttribute($value)
|
||||
{
|
||||
$this->attributes['entry_location'] = DB::raw("ST_SetSRID(ST_Point({$value['lng']}, {$value['lat']}), 4326)");
|
||||
}
|
||||
|
||||
public function setExitLocationAttribute($value)
|
||||
{
|
||||
$this->attributes['exit_location'] = DB::raw("ST_SetSRID(ST_Point({$value['lng']}, {$value['lat']}), 4326)");
|
||||
}
|
||||
|
||||
public function setOfficeLocationAttribute($value)
|
||||
{
|
||||
$this->attributes['office_location'] = DB::raw("ST_SetSRID(ST_Point({$value['lng']}, {$value['lat']}), 4326)");
|
||||
}
|
||||
|
||||
public function breaks()
|
||||
{
|
||||
return $this->hasMany(AttendanceBreak::class);
|
||||
}
|
||||
public $timestamps = true;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AttendanceBreak extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'attendance_id',
|
||||
'break_start',
|
||||
'break_end',
|
||||
];
|
||||
|
||||
// رابطه به حضور
|
||||
public function attendance()
|
||||
{
|
||||
return $this->belongsTo(Attendance::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ai extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user