Skip to content

Commit 455274a

Browse files
committed
Adding Security Log table and model
1 parent 708c495 commit 455274a

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace ProcessMaker\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class SecurityLog extends Model
8+
{
9+
const UPDATED_AT = null;
10+
11+
protected $connection = 'data';
12+
13+
/**
14+
* The attributes that aren't mass assignable.
15+
*
16+
* @var array
17+
*/
18+
protected $guarded = [
19+
'id',
20+
'created_at',
21+
];
22+
23+
/**
24+
* Get the associated user, if any.
25+
*
26+
*/
27+
public function user()
28+
{
29+
return $this->belongsTo('ProcessMaker\Models\User');
30+
}
31+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class CreateSecurityLogsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('security_logs', function (Blueprint $table) {
17+
$table->bigIncrements('id');
18+
$table->string('type', 40)->index();
19+
$table->string('ip', 40)->index()->nullable();
20+
$table->string('user_agent')->nullable();
21+
$table->unsignedInteger('user_id')->nullable();
22+
$table->timestamp('created_at');
23+
24+
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
25+
});
26+
}
27+
28+
/**
29+
* Reverse the migrations.
30+
*
31+
* @return void
32+
*/
33+
public function down()
34+
{
35+
Schema::dropIfExists('security_logs');
36+
}
37+
}

0 commit comments

Comments
 (0)