|
@@ -2,6 +2,9 @@
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
+use Carbon\Carbon;
|
|
|
+use DateTime;
|
|
|
+
|
|
|
# use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
class McpRequest extends Model
|
|
@@ -13,4 +16,37 @@ class McpRequest extends Model
|
|
|
return $this->hasOne(Client::class, 'id', 'for_client_id');
|
|
|
}
|
|
|
|
|
|
+ public function proClientWork()
|
|
|
+ {
|
|
|
+ return $this->hasOne(ProClientWork::class, 'id', 'mcp_pro_client_work_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function createdBy()
|
|
|
+ {
|
|
|
+ return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function createdByName(){
|
|
|
+ $performer = $this->createdBy;
|
|
|
+ if($performer->session_type == 'PRO'){
|
|
|
+ return $performer->pro->name_first.' '.$performer->pro->name_last;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($performer->session_type == 'CLIENT_GUEST'){
|
|
|
+ return $performer->client->name_first.' '.$performer->client->name_last;
|
|
|
+ }
|
|
|
+
|
|
|
+ return "-";
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getWaitTime(){
|
|
|
+ if(!$this->was_claimed){
|
|
|
+ return "-";
|
|
|
+ }
|
|
|
+
|
|
|
+ $created_at = new Carbon($this->created_at);
|
|
|
+ $claimed_at = new Carbon($this->proClientWork->created_at);
|
|
|
+ return $claimed_at->diffForHumans($created_at);
|
|
|
+ }
|
|
|
+
|
|
|
}
|