forked from miguel456/rbrecruiter
RSM-8 Add team files page and ability to download files
This commit is contained in:
38
database/factories/TeamFileFactory.php
Normal file
38
database/factories/TeamFileFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\TeamFile;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TeamFileFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = TeamFile::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$prefix = Storage::disk('local')->getAdapter()->getPathPrefix();
|
||||
|
||||
return [
|
||||
'uploaded_by' => rand(1, 10), // Also assuming that the user seeder has ran before
|
||||
'team_id' => rand(1, 3), // Assuming you create 3 teams beforehand
|
||||
'name' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads', false),
|
||||
'caption' => $this->faker->sentence(),
|
||||
'description' => $this->faker->paragraphs(3, true),
|
||||
'fs_location' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads'),
|
||||
'extension' => 'txt',
|
||||
'size' => rand(1, 1000) // random fake size between 0 bytes and 1 mb
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTeamFilesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('team_files', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('uploaded_by')->unsigned()->index();
|
||||
$table->integer('team_id')->unsigned()->index();
|
||||
$table->string('name');
|
||||
$table->string('fs_location'); // filesystem location
|
||||
$table->string('extension');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('uploaded_by')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
|
||||
$table->foreign('team_id')
|
||||
->references('id')
|
||||
->on('teams')
|
||||
->cascadeOnDelete()
|
||||
->cascadeOnUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('team_files');
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDetailsToTeamFiles extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('team_files', function (Blueprint $table) {
|
||||
$table->integer('size')->nullable()->after('extension');
|
||||
$table->string('caption')->nullable()->after('name');
|
||||
$table->mediumText('description')->nullable()->after('caption');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('team_files', function (Blueprint $table) {
|
||||
$table->dropColumn('size');
|
||||
$table->dropColumn('caption');
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
}
|
@@ -35,5 +35,8 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(PermissionSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
$this->call(DefaultOptionsSeeder::class);
|
||||
$this->call(NewPermissions::class);
|
||||
$this->call(TeamSeeder::class);
|
||||
$this->call(TeamFileSeeder::class);
|
||||
}
|
||||
}
|
||||
|
19
database/seeders/TeamFileSeeder.php
Normal file
19
database/seeders/TeamFileSeeder.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\TeamFile;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TeamFileSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
TeamFile::factory()->count(50)->create();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user