12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Models;
- use Carbon\Carbon;
- use DateTime;
- # use Illuminate\Database\Eloquent\Model;
- class McpRequest extends Model
- {
- protected $table = 'mcp_request';
- public function client()
- {
- 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);
- }
- }
|