# fluent-community/trunk/app/Http/Controllers/Controller.php

FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS &amp; Online Courses, version trunk. 39 lines.

- Page: https://pluginprobe.com/plugins/fluent-community/trunk/code/app/Http/Controllers/Controller.php
- Raw: https://pluginprobe.com/plugins/fluent-community/trunk/raw/app/Http/Controllers/Controller.php
- Modified: 2024-11-07T12:38:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-community/trunk/code/app/Http/Controllers/Controller.php#L10-L20`.

```php
<?php

namespace FluentCommunity\App\Http\Controllers;

use FluentCommunity\App\Models\User;
use FluentCommunity\App\Models\XProfile;
use FluentCommunity\App\Services\Helper;
use FluentCommunity\Framework\Http\Controller as BaseController;

abstract class Controller extends BaseController
{
    /**
     * @return \FluentCommunity\App\Models\User
     */
    public function getUser($throwException = false)
    {
        $user =  Helper::getCurrentUser(true);

        if($throwException && !$user) {
            throw new \Exception(esc_html__('You need to be logged in to perform this action', 'fluent-community'));
        }

        return $user;
    }

    public function getUserId()
    {
        return get_current_user_id();
    }

    /**
     * @return \FluentCommunity\App\Models\XProfile
     */
    public function getXProfile()
    {
        return Helper::getCurrentProfile(true);
    }
}

```
