@@ -10,32 +10,32 @@ |
||
10 | 10 | */ |
11 | 11 | class AccessLog extends Model |
12 | 12 | { |
13 | - /** |
|
14 | - * @var string The database table used by the model. |
|
15 | - */ |
|
16 | - protected $table = 'user_access_log'; |
|
13 | + /** |
|
14 | + * @var string The database table used by the model. |
|
15 | + */ |
|
16 | + protected $table = 'user_access_log'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var array Relations |
|
20 | - */ |
|
21 | - public $belongsTo = [ |
|
22 | - 'user' => ['RainLab\User\Models\User'] |
|
23 | - ]; |
|
18 | + /** |
|
19 | + * @var array Relations |
|
20 | + */ |
|
21 | + public $belongsTo = [ |
|
22 | + 'user' => ['RainLab\User\Models\User'] |
|
23 | + ]; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Creates a log record |
|
27 | - * |
|
28 | - * @param \RainLab\User\Models\User $user Front-end user |
|
29 | - * |
|
30 | - * @return self |
|
31 | - */ |
|
32 | - public static function add($user) |
|
33 | - { |
|
34 | - $record = new static; |
|
35 | - $record->user = $user; |
|
36 | - $record->ip_address = Request::getClientIp(); |
|
37 | - $record->save(); |
|
25 | + /** |
|
26 | + * Creates a log record |
|
27 | + * |
|
28 | + * @param \RainLab\User\Models\User $user Front-end user |
|
29 | + * |
|
30 | + * @return self |
|
31 | + */ |
|
32 | + public static function add($user) |
|
33 | + { |
|
34 | + $record = new static; |
|
35 | + $record->user = $user; |
|
36 | + $record->ip_address = Request::getClientIp(); |
|
37 | + $record->save(); |
|
38 | 38 | |
39 | - return $record; |
|
40 | - } |
|
39 | + return $record; |
|
40 | + } |
|
41 | 41 | } |
@@ -9,31 +9,31 @@ |
||
9 | 9 | class CreateAccessLogTable extends Migration |
10 | 10 | { |
11 | 11 | |
12 | - public function up() |
|
13 | - { |
|
14 | - Schema::create('user_access_log', function($table) |
|
15 | - { |
|
16 | - $table->engine = 'InnoDB'; |
|
17 | - $table->increments('id'); |
|
18 | - |
|
19 | - $table->integer('user_id')->unsigned()->nullable(); |
|
20 | - $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); |
|
21 | - |
|
22 | - $table->string('ip_address')->nullable(); |
|
23 | - |
|
24 | - $table->timestamps(); |
|
25 | - }); |
|
26 | - } |
|
27 | - |
|
28 | - public function down() |
|
29 | - { |
|
30 | - DB::statement("SET foreign_key_checks = 0"); |
|
31 | - Schema::table('user_access_log', function($table) |
|
32 | - { |
|
33 | - $table->dropForeign('user_access_log_user_id_foreign'); |
|
34 | - }); |
|
35 | - Schema::dropIfExists('user_access_log'); |
|
36 | - DB::statement("SET foreign_key_checks = 1"); |
|
37 | - } |
|
12 | + public function up() |
|
13 | + { |
|
14 | + Schema::create('user_access_log', function($table) |
|
15 | + { |
|
16 | + $table->engine = 'InnoDB'; |
|
17 | + $table->increments('id'); |
|
18 | + |
|
19 | + $table->integer('user_id')->unsigned()->nullable(); |
|
20 | + $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); |
|
21 | + |
|
22 | + $table->string('ip_address')->nullable(); |
|
23 | + |
|
24 | + $table->timestamps(); |
|
25 | + }); |
|
26 | + } |
|
27 | + |
|
28 | + public function down() |
|
29 | + { |
|
30 | + DB::statement("SET foreign_key_checks = 0"); |
|
31 | + Schema::table('user_access_log', function($table) |
|
32 | + { |
|
33 | + $table->dropForeign('user_access_log_user_id_foreign'); |
|
34 | + }); |
|
35 | + Schema::dropIfExists('user_access_log'); |
|
36 | + DB::statement("SET foreign_key_checks = 1"); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |