Add our table names to our models, since they are not determined automatically

This commit is contained in:
Deon George 2022-08-24 12:07:39 +10:00
parent 6b27945142
commit 5f14be0cae
6 changed files with 10 additions and 3 deletions

View File

@ -54,6 +54,7 @@ class SlackAppController extends Controller
* Install this Slack Application.
*
* @param Request $request
* @param bool $oauth
* @return string
* @throws \GuzzleHttp\Exception\GuzzleException
*/

View File

@ -13,6 +13,7 @@ class Channel extends Model
use ScopeActive;
protected $fillable = ['team_id','channel_id','name','active'];
protected $table = 'slack_channels';
/* RELATIONS */

View File

@ -12,6 +12,7 @@ class Enterprise extends Model
use ScopeActive;
protected $fillable = ['enterprise_id'];
protected $table = 'slack_enterprises';
/* RELATIONS */

View File

@ -15,6 +15,7 @@ class Team extends Model
use ScopeActive;
protected $fillable = ['team_id'];
protected $table = 'slack_teams';
/* RELATIONS */

View File

@ -12,6 +12,8 @@ class Token extends Model
{
use ScopeActive;
protected $table = 'slack_tokens';
/* RELATIONS */
public function team()

View File

@ -17,6 +17,7 @@ class User extends Model
protected const LOGKEY = '-MU';
protected $fillable = ['user_id'];
protected $table = 'slack_users';
/* RELATIONS */
@ -52,15 +53,15 @@ class User extends Model
/**
* 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
*
* @return mixed
* @return Team|null
*/
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);
}