Skip to content
Snippets Groups Projects
Commit 18949da6 authored by btalhaoui's avatar btalhaoui
Browse files

Use token instead of server_id for the web interface

parent 50e9b937
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ class Sensors extends Moloquent
{
protected $connection = 'mongodb';
protected $collection = 'sensors';
protected $fillable = ['id','content','server_id'];
protected $fillable = ['id','content','token'];
protected $server;
public function server($id)
......
......@@ -17,7 +17,7 @@ class Server extends Model
public function sensors()
{
$sensors = Sensors::where("server_id","".$this->getKey())->get();
$sensors = Sensors::where("token","".$this->token)->get();
foreach($sensors as $sensor){
$sensor["content"] = json_decode($sensor["content"]);
}
......@@ -25,7 +25,7 @@ class Server extends Model
}
public function getLastState()
{
$sensor = Sensors::where("server_id","".$this->getKey())->orderBy('created_at', 'desc')->first();
$sensor = Sensors::where("token","".$this->token)->orderBy('created_at', 'desc')->first();
$sensor["content"] = json_decode($sensor["content"]);
return $this->lastState = $sensor;
......
......@@ -16,6 +16,7 @@ class CreateServersTable extends Migration
Schema::create('servers', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('token');
$table->integer('organization_id')->unsigned();
$table->foreign('organization_id')
->references('id')->on('organizations')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment