123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Http\Traits;
- use App\Models\AppSession;
- trait KeysIdsTrait
- {
- public function getId ($object)
- {
- if( !$object) {
- return false;
- }
- if( !$object->id) {
- return false;
- }
- return $object->id;
- }
-
- public function getIid ($object)
- {
- if( !$object) {
- return false;
- }
- if( !$object->iid) {
- return false;
- }
- return $object->iid;
- }
-
- public function getUid ($object)
- {
- if( !$object) {
- return false;
- }
- if( !$object->uid) {
- return false;
- }
- return $object->uid;
- }
-
- public function saveForeignKey ($object)
- {
- return $object->id;
- }
-
- public function getCurrentSessionId ()
- {
- return request()->cookie("credo_session_key");
- }
-
- public function getCurrentAgentId ()
- {
- $sessionKey = $this->getCurrentSessionId();
- $appSession = AppSession::where("session_key", $sessionKey)->first();
- return $appSession->agent->uid;
- }
- }
|