This commit is contained in:
mobin
2025-10-11 13:38:30 +00:00
parent 1c5d2c6f10
commit 2adb741dac
61 changed files with 3370 additions and 413 deletions
+41 -41
View File
@@ -28,47 +28,47 @@ class RunAiJob extends Command
*/
public function handle()
{
$response = Http::withHeaders([
'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjA2OWZlZGJiLTk2ZDctNGU4MC1iMDA0LWFmZDZjMmU4YmZkZiIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTQ3NTcxMDR9.qAQF8XDOU8NRz5vSiFlQfnrj8dhGhJ5uvJqjblQWmr8',
'Cookie' => 'x-ap=eu-central-1; acw_tc=0a03e56c17521661095906021e3cacb270c127c80eb3a20489a465ab4beae1',
])->post('https://chat.qwen.ai/api/v2/chat/completions?chat_id=7ce2a60a-2b40-4ae8-8536-0cd346642de3', [
'stream' => false,
'incremental_output' => true,
'chat_id' => '7ce2a60a-2b40-4ae8-8536-0cd346642de3',
'chat_mode' => 'normal',
'model' => 'qwen3-235b-a22b',
'messages' => [
[
'role' => 'user',
'content' => 'یه جمله انگیزشی بده که خاص، کوبنده و غیرکلیشه‌ای باشه. نه مثل بقیه.',
'user_action' => 'chat',
'files' => [],
'timestamp' => 1752165316,
'models' => ['qwen3-235b-a22b'],
'chat_type' => 't2t',
'feature_config' => [
'thinking_enabled' => false,
'output_schema' => 'phase'
],
'extra' => [
'meta' => [
'subChatType' => 't2t'
]
],
'sub_chat_type' => 't2t',
'parent_id' => 'df0a0c91-53d5-4a04-b5da-b8ac53d6d821'
]
],
'timestamp' => 1752165316
]);
// Get the response
$responseData = $response->json();
$content = $responseData['data']['choices'][0]['message']['content'];
$ai = new ai(); // Or use your correct namespace
$ai->key = 'angizeh'; // Assuming you fixed 'kay' to 'key' in migration
$ai->prompt = 'فقط یک جمله کوتاه انگیزشی بگو';
$ai->response = $content;
$ai->save();
// $response = Http::withHeaders([
// 'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjA2OWZlZGJiLTk2ZDctNGU4MC1iMDA0LWFmZDZjMmU4YmZkZiIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTQ3NTcxMDR9.qAQF8XDOU8NRz5vSiFlQfnrj8dhGhJ5uvJqjblQWmr8',
// 'Cookie' => 'x-ap=eu-central-1; acw_tc=0a03e56c17521661095906021e3cacb270c127c80eb3a20489a465ab4beae1',
// ])->post('https://chat.qwen.ai/api/v2/chat/completions?chat_id=7ce2a60a-2b40-4ae8-8536-0cd346642de3', [
// 'stream' => false,
// 'incremental_output' => true,
// 'chat_id' => '7ce2a60a-2b40-4ae8-8536-0cd346642de3',
// 'chat_mode' => 'normal',
// 'model' => 'qwen3-235b-a22b',
// 'messages' => [
// [
// 'role' => 'user',
// 'content' => 'یه جمله انگیزشی بده که خاص، کوبنده و غیرکلیشه‌ای باشه. نه مثل بقیه.',
// 'user_action' => 'chat',
// 'files' => [],
// 'timestamp' => 1752165316,
// 'models' => ['qwen3-235b-a22b'],
// 'chat_type' => 't2t',
// 'feature_config' => [
// 'thinking_enabled' => false,
// 'output_schema' => 'phase'
// ],
// 'extra' => [
// 'meta' => [
// 'subChatType' => 't2t'
// ]
// ],
// 'sub_chat_type' => 't2t',
// 'parent_id' => 'df0a0c91-53d5-4a04-b5da-b8ac53d6d821'
// ]
// ],
// 'timestamp' => 1752165316
// ]);
//// Get the response
// $responseData = $response->json();
// $content = $responseData['data']['choices'][0]['message']['content'];
// $ai = new ai(); // Or use your correct namespace
// $ai->key = 'angizeh'; // Assuming you fixed 'kay' to 'key' in migration
// $ai->prompt = 'فقط یک جمله کوتاه انگیزشی بگو';
// $ai->response = $content;
// $ai->save();
$this->info('AI Job dispatched successfully!');
}
}
View File
Regular → Executable
View File
+38
View File
@@ -4,9 +4,12 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class Attendance extends Model
{
// protected $appends = ['full_time'];
protected $fillable = [
'user_id',
'user_identity',
@@ -21,6 +24,7 @@ class Attendance extends Model
'ip_address',
'entered_at',
'exited_at',
'requested',
];
public function setEntryLocationAttribute($value)
@@ -42,5 +46,39 @@ class Attendance extends Model
{
return $this->hasMany(AttendanceBreak::class);
}
public function duration($start,$end)
{
// 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);
$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;
}
// public function attendanceBreak()
// {
//
// return $this->hasMany(AttendanceBreak::class, 'attendance_id', 'id')
// ->select('attendance_id', 'break_start', 'break_end', 'duration')
// ->orderBy('break_start', 'desc');
//
//
// }
public function attendanceBreaks()
{
return $this->hasMany(AttendanceBreak::class, 'attendance_id', 'id')
->orderBy('break_start', 'desc');
}
public $timestamps = true;
}
Regular → Executable
+1
View File
@@ -11,6 +11,7 @@ class AttendanceBreak extends Model
'attendance_id',
'break_start',
'break_end',
'duration',
];
// رابطه به حضور
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Tasks extends Model
{
use HasFactory;
protected $table = 'tasks';
// protected $primaryKey = 'id'; // چون جدول UUID داره
// public $incrementing = false;
// protected $keyType = 'int';
protected $fillable = [
'task_id',
'name',
'description',
'workspace_slug',
'assignees',
'start_date',
'target_date',
'priority',
'description_html',
'completed_at',
'project',
'workspace',
'state',
'json',
'created_at',
'updated_at',
'deleted_at',
'created_by',
'updated_by',
'deleted_by',
];
// رابطه 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)
);
}
}
Regular → Executable
+74 -9
View File
@@ -3,24 +3,36 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Morilog\Jalali\Jalalian;
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',
'chatid',
'name',
'number',
'password',
'user_name',
'is_admin',
'plain_id',
];
/**
@@ -28,10 +40,7 @@ class User extends Authenticatable
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
protected $hidden = [];
/**
* Get the attributes that should be cast.
@@ -40,9 +49,65 @@ class User extends Authenticatable
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
return [];
}
public function tasks()
{
// return $this->belongsToMany(Tasks::class, 'pivot_tasks', 'user_id', 'task_id');
return $this->belongsToMany(
Tasks::class, // مدل مقصد
'pivot_tasks', // جدول واسط
'user_id', // ستون جدول واسط که به جدول users اشاره می‌کنه
'task_id', // ستون جدول واسط که به جدول tasks اشاره می‌کنه
'plain_id', // ستون جدول users که ستون جدول واسط بهش اشاره می‌کنه (local key)
'task_id' // ستون جدول tasks که ستون جدول واسط بهش اشاره می‌کنه (related key)
);
}
public function attendances()
{
return $this->hasMany(Attendance::class, 'user_identity', 'user_name')
->select('id', 'user_identity', 'entered_at', 'exited_at', 'duration','requested')
->orderBy('entered_at', 'desc');
}
public function attendanceBreaks()
{
return $this->hasManyThrough(AttendanceBreak::class,Attendance::class,'user_identity','attendance_id',
'user_name', // local key در users
'id' // local key در attendances
);
}
public function thismonth($data)
{
}
public function everymonth($data)
{
$result = [];
foreach ($data->attendances as $att) {
if ($att->entered_at) {
$date = \Morilog\Jalali\Jalalian::fromCarbon(\Carbon\Carbon::parse($att->entered_at));
$month = $date->format('%B');
if (!isset($result[$month])) {
$result[$month] = [];
}
$result[$month][] = $att;
}
}
return $result;
}
}
Regular → Executable
View File
+1 -1
View File
@@ -19,6 +19,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
}
}