Skip to content

Commit

Permalink
Merge pull request #4 from ARCANEDEV/dev
Browse files Browse the repository at this point in the history
Updating the package
  • Loading branch information
arcanedev-maroc authored Feb 11, 2017
2 parents 1ab9a2d + d1df89a commit 14874e2
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ before_script:
script:
- composer validate
- mkdir -p build/logs
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover

after_script:
- if [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"arcanedev/support": "~3.0"
},
"require-dev": {
"phpunit/phpcov": "~2.0|~3.0",
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpcov": "~3.0",
"phpunit/phpunit": "~5.0"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 4 additions & 4 deletions src/Bases/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
*/
abstract class Migration extends BaseMigration
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Traits
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
use ConfigHelper;

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Migration constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Bases/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ abstract class Model extends BaseModel
*/
use ConfigHelper;

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Create a new Eloquent model instance.
Expand Down
25 changes: 16 additions & 9 deletions src/Contracts/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
interface Discussion
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Relationships
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Participants relationship.
Expand All @@ -44,16 +44,23 @@ public function participants();
*/
public function messages();

/**
* User's relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function users();

/**
* Get the user that created the first message.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function creator();

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Scopes
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Scope discussions that the user is associated with.
Expand Down Expand Up @@ -96,9 +103,9 @@ public function scopeBetween(Builder $query, array $userIds);
*/
public function scopeSubject(Builder $query, $subject, $strict = false);

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get the latest_message attribute.
Expand All @@ -107,9 +114,9 @@ public function scopeSubject(Builder $query, $subject, $strict = false);
*/
public function getLatestMessageAttribute();

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Returns all of the latest discussions by `updated_at` date.
Expand Down
8 changes: 4 additions & 4 deletions src/Contracts/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/
interface Message
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Relationships
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Discussion relationship.
Expand Down Expand Up @@ -52,9 +52,9 @@ public function user();
*/
public function participants();

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Recipients of this message.
Expand Down
14 changes: 7 additions & 7 deletions src/Contracts/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
interface Participant
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Relationships
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Discussion relationship.
Expand All @@ -36,9 +36,9 @@ public function discussion();
*/
public function user();

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get the participant string info.
Expand All @@ -47,9 +47,9 @@ public function user();
*/
public function stringInfo();

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Restore a soft-deleted model instance.
Expand Down
24 changes: 13 additions & 11 deletions src/LaravelMessengerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php namespace Arcanedev\LaravelMessenger;

use Arcanedev\LaravelMessenger\Contracts as MessengerContracts;
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
use Arcanedev\Support\PackageServiceProvider;

/**
* Class LaravelMessengerServiceProvider
*
* @package Arcanedev\LaravelMessenger
* @author ARCANEDEV <[email protected]>
*/
class LaravelMessengerServiceProvider extends ServiceProvider
class LaravelMessengerServiceProvider extends PackageServiceProvider
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Package name.
Expand All @@ -22,9 +22,9 @@ class LaravelMessengerServiceProvider extends ServiceProvider
*/
protected $package = 'laravel-messenger';

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get the base path of the package.
Expand All @@ -36,15 +36,17 @@ public function getBasePath()
return dirname(__DIR__);
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Register the service provider.
*/
public function register()
{
parent::register();

$this->registerConfig();
$this->bindModels();
}
Expand Down Expand Up @@ -74,9 +76,9 @@ public function provides()
];
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/
/**
* Bind the models.
Expand Down
45 changes: 30 additions & 15 deletions src/Models/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
*/
class Discussion extends Model implements DiscussionContract
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Traits
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
use SoftDeletes;

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* The attributes that can be set with Mass Assignment.
Expand All @@ -67,9 +67,9 @@ class Discussion extends Model implements DiscussionContract
'id' => 'integer',
];

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Create a new Eloquent model instance.
Expand All @@ -85,9 +85,9 @@ public function __construct(array $attributes = [])
parent::__construct($attributes);
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Relationships
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Participants relationship.
Expand All @@ -113,6 +113,21 @@ public function messages()
);
}

/**
* User's relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function users()
{
return $this->belongsToMany(
$this->getModelFromConfig('users', \App\User::class),
'participants',
'discussion_id',
'user_id'
);
}

/**
* Get the user that created the first message.
*
Expand All @@ -123,9 +138,9 @@ public function creator()
return $this->messages()->oldest()->first()->user();
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Scopes
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Scope discussions that the user is associated with.
Expand Down Expand Up @@ -215,9 +230,9 @@ public function scopeSubject(Builder $query, $subject, $strict = false)
return $query->where('subject', 'like', $subject);
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get the latest_message attribute.
Expand All @@ -229,9 +244,9 @@ public function getLatestMessageAttribute()
return $this->messages->sortByDesc('created_at')->first();
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Returns all of the latest discussions by `updated_at` date.
Expand Down
16 changes: 8 additions & 8 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*/
class Message extends Model implements MessageContract
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* The relationships that should be touched on save.
Expand All @@ -50,9 +50,9 @@ class Message extends Model implements MessageContract
'id' => 'integer',
];

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Create a new Eloquent model instance.
Expand All @@ -68,9 +68,9 @@ public function __construct(array $attributes = [])
parent::__construct($attributes);
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Relationships
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Discussion relationship.
Expand Down Expand Up @@ -120,9 +120,9 @@ public function participants()
);
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Recipients of this message.
Expand Down
Loading

0 comments on commit 14874e2

Please sign in to comment.