vendor and env first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Vanguard\UserActivity\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Vanguard\User;
|
||||
use Vanguard\UserActivity\Activity;
|
||||
|
||||
class ActivityFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = Activity::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'description' => substr($this->faker->paragraph, 0, 255),
|
||||
'ip_address' => $this->faker->ipv4,
|
||||
'user_agent' => $this->faker->userAgent,
|
||||
];
|
||||
}
|
||||
}
|
||||
vendor/vanguardapp/activity-log/database/migrations/2015_12_29_224252_create_user_activity_table.php
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateUserActivityTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_activity', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->text('description');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->string('ip_address', 45);
|
||||
$table->text('user_agent');
|
||||
$table->timestamp('created_at');
|
||||
});
|
||||
|
||||
Schema::table('user_activity', function (Blueprint $table) {
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (DB::getDriverName() != 'sqlite') {
|
||||
Schema::table('user_activity', function (Blueprint $table) {
|
||||
$table->dropForeign('user_activity_user_id_foreign');
|
||||
});
|
||||
}
|
||||
|
||||
Schema::drop('user_activity');
|
||||
|
||||
\DB::table('permissions')->where('name', 'users.activity')->delete();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Vanguard\UserActivity\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Vanguard\Permission;
|
||||
use Vanguard\Role;
|
||||
|
||||
class ActivityPermissionsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$adminRole = Role::where('name', 'Admin')->first();
|
||||
|
||||
$permission = Permission::create([
|
||||
'name' => 'users.activity',
|
||||
'display_name' => 'View System Activity Log',
|
||||
'description' => 'View activity log for all system users.',
|
||||
'removable' => false,
|
||||
]);
|
||||
|
||||
$adminRole->attachPermission($permission);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user