mirror of https://github.com/movim/movim
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
928 B
40 lines
928 B
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Invite extends Model
|
|
{
|
|
public $primaryKey = 'code';
|
|
protected $keyType = 'string';
|
|
public $incrementing = false;
|
|
protected $fillable = ['code'];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User');
|
|
}
|
|
|
|
public function room()
|
|
{
|
|
return $this->hasOne('App\Contact', 'id', 'resource');
|
|
}
|
|
|
|
public static function set($jid, $resource)
|
|
{
|
|
$invitation = \App\Invite::where('user_id', $jid)
|
|
->where('resource', $resource)
|
|
->first();
|
|
|
|
if (!$invitation) {
|
|
$invitation = new \App\Invite;
|
|
$invitation->code = generateKey(8);
|
|
$invitation->user_id = $jid;
|
|
$invitation->resource = $resource;
|
|
$invitation->save();
|
|
}
|
|
|
|
return $invitation;
|
|
}
|
|
}
|