Help
General ArrowChat talk that doesn't fit any other forum.
User avatar
merlinofuentesgiron
Free
 
Posts: 1
Joined: 04 May 2019, 19:15

 

by merlinofuentesgiron 04 May 2019, 19:20

Hello any can share the integration.php for Laravel 5? Thanks in advance.
User avatar
ollyweston
Free
 
Posts: 1
Joined: 23 Dec 2019, 19:39

 

by ollyweston 23 Dec 2019, 19:43

Well I' m here for the same..
User avatar
TPonsky
Customer
 
Posts: 12
Joined: 26 May 2020, 08:07

 

by TPonsky 18 Aug 2020, 19:19

I have done it. I put the arrow chat content in a folder in public called chat. Then I edited the database configuration code and installed arrowchat into the same database as my laravel system with the arrowchat_ prefix.

Then I modified the integration.php file in public/chat/includes folder
Code: Select all
// this function uses the userid cookie I have getting set by the laravel system.
function get_user_id()
{
    $userid = NULL;

    if (isset($_COOKIE['userid']))
    {
        $userid = $_COOKIE['userid'];
    }

    return $userid;
}
There's a bunch of other functions in there that may need some minor manipulation based on your db structure.
User avatar
Jason
Customer
 
Posts: 2329
Joined: 12 Dec 2009, 16:06

 

by Jason 18 Aug 2020, 20:20

Laravel really depends on a million different things, so the code that I'm providing may or may not work, but we have used this for Laravel before. This might at least get someone started.

In the includes/config.php file, you need to include some files:
Code: Select all
include_once( dirname(dirname(dirname(__FILE__))).'/bootstrap/autoload.php');
include_once( dirname(dirname(dirname(__FILE__))).'/bootstrap/app.php');
include_once( dirname(dirname(dirname(__FILE__))).'/app/Http/Controllers/Auth/app.php');
and the includes/integration.php file's get_user_id function:
Code: Select all
	function get_user_id() 
	{
		$userid = NULL;
		
		if (!empty($_COOKIE['laravel_session'])) 
		{
			$app = app();
			$kernel = $app->make('Illuminate\Contracts\Http\Kernel');
			$response = $kernel->handle(
				$request = Illuminate\Http\Request::capture()
				);
			$id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]);
			$app['session']->driver()->setId($id);
			$app['session']->driver()->start();
			if($app['auth']->user()!= NULL){
				$userid = $app['auth']->user()->id;
			}
		}

		return $userid;
	}