Skip to content

Commit

Permalink
Updated routes and Pulse/User controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonscott committed May 5, 2014
1 parent 11d03a0 commit aa03eb6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
33 changes: 33 additions & 0 deletions app/controllers/PulseController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
class PulseController extends BaseController{

public function getAll()
{

return Response::json(Pulse::all());
}

public function store()
{
$pulse = new Pulse;

$pulse->server_id = Input::get("server_id");
$pulse->ram_usage = Input::get("ram_usage");
$pulse->cpu_usage = Input::get("cpu_usage");
$pulse->disk_usage = Input::get("disk_usage");
$pulse->uptime = Input::get("uptime");
$pulse->timestamp = Input::get("timestamp");

$pulse->save();

$pubnub = App::make('pubnub');
$pubnub->publish(array(
'channel' => 'Cadence',
'message' => json_decode($pulse)
));

return Response::json($pulse);

}
}
?>
23 changes: 23 additions & 0 deletions app/models/Pulse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

class Pulse extends Eloquent {

/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $fillable = array('ram_usage', 'cpu_usage', 'disk_usage', 'uptime', 'timestamp');
protected $guarded = array('id', 'server_id');
public $timestamps = false;

/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
}
13 changes: 2 additions & 11 deletions app/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@

class User extends Eloquent implements UserInterface, RemindableInterface {

/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';

/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password');

protected $fillable = array('email', 'firstname', 'lastname');
protected $guarded = array('id', 'password');
protected $fillable = array('email', 'first_name', 'last_name', 'mobile_number');
protected $guarded = array('id', 'password', 'password_salt', 'privilege_id');
public $timestamps = false;

/**
Expand Down Expand Up @@ -62,6 +55,4 @@ public function store()
{
//
}


}
2 changes: 2 additions & 0 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Route::get('/users', 'UserController@getAll');
Route::get('/users/store', 'UserController@store');

Route::get('/pulse', 'PulseController@getAll');
Route::post('/pulse', 'PulseController@store');

Route::any('/pubnub', 'pubnub::simplechat@index');
Route::any('(:bundle)/login', 'pubnub::simplechat@login');
Expand Down
4 changes: 2 additions & 2 deletions app/start/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@

App::singleton('pubnub', function()
{
$publish_key = Config::get('pubnub::pubnub.publish_key');
$subscribe_key = Config::get('pubnub::pubnub.subscribe_key');
$publish_key = Config::get('pubnub.publish_key');
$subscribe_key = Config::get('pubnub.subscribe_key');

return new Pubnub($publish_key, $subscribe_key);
});

0 comments on commit aa03eb6

Please sign in to comment.