Skip to content

Commit

Permalink
Use coenjacobs/eloquent-composite-primary-keys
Browse files Browse the repository at this point in the history
Bump the version to PHP7.0+
  • Loading branch information
edhelas committed Mar 25, 2018
1 parent f302a13 commit 98e4825
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 236 deletions.
7 changes: 5 additions & 2 deletions app/Presence.php
Expand Up @@ -2,11 +2,14 @@

namespace App;

use CoenJacobs\EloquentCompositePrimaryKeys\HasCompositePrimaryKey;
use Illuminate\Database\Eloquent\Model;

class Presence extends Model
{
protected $primaryKey = 'session_id';
use HasCompositePrimaryKey;

protected $primaryKey = ['session_id', 'jid', 'resource'];
public $incrementing = false;

protected $attributes = [
Expand Down Expand Up @@ -63,7 +66,7 @@ public function set($stanza)
$this->resource = '';
}

if ($stanza->status) {
if ($stanza->status && !empty((string)$stanza->status)) {
$this->status = (string)$stanza->status;
}

Expand Down
5 changes: 4 additions & 1 deletion app/Roster.php
Expand Up @@ -2,13 +2,16 @@

namespace App;

use CoenJacobs\EloquentCompositePrimaryKeys\HasCompositePrimaryKey;
use Illuminate\Database\Eloquent\Model;
use Movim\Picture;

class Roster extends Model
{
use HasCompositePrimaryKey;

public $incrementing = false;
protected $primaryKey = 'jid';
protected $primaryKey = ['session_id', 'jid'];
protected $fillable = ['jid', 'name', 'ask', 'subscription', 'group'];

protected $attributes = [
Expand Down
10 changes: 6 additions & 4 deletions app/widgets/Chats/Chats.php
Expand Up @@ -38,12 +38,14 @@ function onMessage($packet)

function onPresence($packet)
{
$contacts = $packet->content;
if ($contacts != null){
if ($packet->content != null){
$c = $contacts[0];
$chats = \App\Cache::c('chats');
if (is_array($chats) && array_key_exists($c->jid, $chats)) {
$this->rpc('MovimTpl.replace', '#' . cleanupId($c->jid.'_chat_item'), $this->prepareChat($c->jid));
if (is_array($chats) && array_key_exists($packet->content->jid, $chats)) {
$this->rpc(
'MovimTpl.replace',
'#' . cleanupId($c->jid.'_chat_item'),
$this->prepareChat($packet->content->jid));
$this->rpc('Chats.refresh');

$n = new Notification;
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -8,7 +8,7 @@
}
},
"require": {
"php": ">=5.6.0",
"php": ">=7.0.0",
"ext-curl": "*",
"ext-mbstring": "*",
"ext-imagick": "*",
Expand Down Expand Up @@ -38,11 +38,12 @@
"react/child-process": "^0.5.0",
"clue/buzz-react": "^2.1",
"illuminate/database": "^5.2",
"robmorgan/phinx": "^0.9.2"
"robmorgan/phinx": "^0.9.2",
"coenjacobs/eloquent-composite-primary-keys": "^1.0"
},
"config": {
"platform": {
"php": "5.6"
"php": "7.0"
}
}
}

0 comments on commit 98e4825

Please sign in to comment.