Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.8 kB
3
Indexable
Never
$whitelabel_slug = \Input::has('whitelabel_slug') ? \Input::get('whitelabel_slug') : null;
            $room_owner_id = $this->getLoggedUserId();
            if (isset($whitelabel_slug)) {
                $whitelabel = \WhitelabelPartner::where('slug', $whitelabel_slug)->first();
                if (!isset($whitelabel)) {
                    return API::response()->array([
                        'return' => false,
                        'output' => [],
                        'extra' =>  [
                            'message' => 'Whitelabel not found'
                        ]
                    ])->statusCode(400);
                }
                if ($whitelabel->user_id !== $room_owner_id) {
                    $membership = WhitelabelMember::where('user_id', $this->getLoggedUserId())->where('whitelabel_partner_id', $whitelabel->id)->where(function($query) {
                        $query->where('role', 'admin')->orWhere('role', 'editor');
                    })->first();
                    if (!$membership) {
                        return API::response()->array([
                            'return' => false,
                            'extra' => [
                                'message' => 'Not authorised to create event!'
                            ]
                        ])->statusCode(401);
                    }
                    $room_owner_id = $whitelabel->user_id;
                }
            }
            if ($event->user_id !== $room_owner_id) {
                return API::response()->array([
                    'return' => false,
                    'extra' => [
                        'message' => 'Not authorised to delete event!'
                    ]
                ])->statusCode(401);
            }