7 changed files with 88 additions and 30 deletions
-
33app/Invite.php
-
2app/controllers/LoginController.php
-
4app/widgets/Login/Login.php
-
5app/widgets/Rooms/Rooms.php
-
10app/widgets/Rooms/_rooms_invite.tpl
-
36composer.lock
-
28database/migrations/20180401144542_create_invites_table.php
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
namespace App; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Invite extends Model |
|||
{ |
|||
public $primaryKey = 'code'; |
|||
public $incrementing = false; |
|||
|
|||
public function user() |
|||
{ |
|||
return $this->belongsTo('App\User'); |
|||
} |
|||
|
|||
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; |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
<?php |
|||
|
|||
use Movim\Migration; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
|
|||
class CreateInvitesTable extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->schema->create('invites', function(Blueprint $table) { |
|||
$table->string('code', 8); |
|||
$table->string('user_id', 64); |
|||
$table->string('resource', 128); |
|||
$table->timestamps(); |
|||
|
|||
$table->primary('code'); |
|||
$table->foreign('user_id') |
|||
->references('id')->on('users') |
|||
->onDelete('cascade'); |
|||
}); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->schema->drop('invites'); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue