Add our table names to our models, since they are not determined automatically
This commit is contained in:
parent
6b27945142
commit
5f14be0cae
@ -54,6 +54,7 @@ class SlackAppController extends Controller
|
|||||||
* Install this Slack Application.
|
* Install this Slack Application.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
* @param bool $oauth
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
*/
|
*/
|
||||||
|
@ -13,6 +13,7 @@ class Channel extends Model
|
|||||||
use ScopeActive;
|
use ScopeActive;
|
||||||
|
|
||||||
protected $fillable = ['team_id','channel_id','name','active'];
|
protected $fillable = ['team_id','channel_id','name','active'];
|
||||||
|
protected $table = 'slack_channels';
|
||||||
|
|
||||||
/* RELATIONS */
|
/* RELATIONS */
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class Enterprise extends Model
|
|||||||
use ScopeActive;
|
use ScopeActive;
|
||||||
|
|
||||||
protected $fillable = ['enterprise_id'];
|
protected $fillable = ['enterprise_id'];
|
||||||
|
protected $table = 'slack_enterprises';
|
||||||
|
|
||||||
/* RELATIONS */
|
/* RELATIONS */
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class Team extends Model
|
|||||||
use ScopeActive;
|
use ScopeActive;
|
||||||
|
|
||||||
protected $fillable = ['team_id'];
|
protected $fillable = ['team_id'];
|
||||||
|
protected $table = 'slack_teams';
|
||||||
|
|
||||||
/* RELATIONS */
|
/* RELATIONS */
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ class Token extends Model
|
|||||||
{
|
{
|
||||||
use ScopeActive;
|
use ScopeActive;
|
||||||
|
|
||||||
|
protected $table = 'slack_tokens';
|
||||||
|
|
||||||
/* RELATIONS */
|
/* RELATIONS */
|
||||||
|
|
||||||
public function team()
|
public function team()
|
||||||
|
@ -17,6 +17,7 @@ class User extends Model
|
|||||||
protected const LOGKEY = '-MU';
|
protected const LOGKEY = '-MU';
|
||||||
|
|
||||||
protected $fillable = ['user_id'];
|
protected $fillable = ['user_id'];
|
||||||
|
protected $table = 'slack_users';
|
||||||
|
|
||||||
/* RELATIONS */
|
/* RELATIONS */
|
||||||
|
|
||||||
@ -52,15 +53,15 @@ class User extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the team that this user is in - normally required to get the team token
|
* Return the team that this user is in - normally required to get the team token
|
||||||
* For enterprise users, any team token will do.
|
* For enterprise users, any team token will do, so we choose the first team of the enteprise
|
||||||
*
|
*
|
||||||
* If the integration is not installed in any channels, team will be blank
|
* If the integration is not installed in any channels, team will be blank
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Team|null
|
||||||
*/
|
*/
|
||||||
public function getUserTeamAttribute(): ?Team
|
public function getUserTeamAttribute(): ?Team
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('%s:User [%s]',self::LOGKEY,$this->id),['team'=>$this->team_id,'enterprise'=>$this->enterprise_id,'eo'=>$this->enterprise]);
|
Log::debug(sprintf('%s:User [%s], Team [%s], Enterprise [%s]',self::LOGKEY,$this->id,$this->team_id,$this->enterprise_id),['m'=>__METHOD__]);
|
||||||
|
|
||||||
return $this->team_id ? $this->team : (($x=$this->enterprise->teams) ? $x->first() : NULL);
|
return $this->team_id ? $this->team : (($x=$this->enterprise->teams) ? $x->first() : NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user