work with databases
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Has been cancelled Details

This commit is contained in:
aslan 2024-05-02 16:54:51 +03:00
parent 01081d6ae9
commit c5c17f0d58
26 changed files with 175 additions and 133 deletions

View File

@ -13,7 +13,8 @@ class LabelController extends Controller
*/ */
public function index() public function index()
{ {
// $labels = Label::all();
return view('admin.labels.index', compact('labels'));
} }
/** /**

View File

@ -4,20 +4,12 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Department>
*/
class DepartmentFactory extends Factory class DepartmentFactory extends Factory
{ {
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
// 'name' => fake()->name(),
]; ];
} }
} }

View File

@ -4,20 +4,13 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Label>
*/
class LabelFactory extends Factory class LabelFactory extends Factory
{ {
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
// 'name' => fake()->name(),
'description' => fake()->text(),
]; ];
} }
} }

View File

@ -4,20 +4,15 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Note>
*/
class NoteFactory extends Factory class NoteFactory extends Factory
{ {
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
// 'name' => fake()->name(),
'file' => fake()->name(),
'description' => fake()->text(),
'task_id' => 1,
]; ];
} }
} }

View File

@ -4,20 +4,18 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Task>
*/
class TaskFactory extends Factory class TaskFactory extends Factory
{ {
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
// 'name' => fake()->name(),
'file' => fake()->name(),
'description' => fake()->text(),
'parent_id' => 0,
'status_id' => 1,
'department_id' => 1,
'created_by_id' => 1,
]; ];
} }
} }

View File

@ -4,20 +4,12 @@ namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TaskStatuses>
*/
class TaskStatusesFactory extends Factory class TaskStatusesFactory extends Factory
{ {
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
// 'name' => fake()->name(),
]; ];
} }
} }

View File

@ -6,21 +6,10 @@ use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str; use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory class UserFactory extends Factory
{ {
/**
* The current password being used by the factory.
*/
protected static ?string $password; protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array public function definition(): array
{ {
return [ return [
@ -32,9 +21,6 @@ class UserFactory extends Factory
]; ];
} }
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static public function unverified(): static
{ {
return $this->state(fn (array $attributes) => [ return $this->state(fn (array $attributes) => [

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('users', function (Blueprint $table) { Schema::create('users', function (Blueprint $table) {
@ -37,9 +34,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('users'); Schema::dropIfExists('users');

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('cache', function (Blueprint $table) { Schema::create('cache', function (Blueprint $table) {
@ -24,9 +21,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('cache'); Schema::dropIfExists('cache');

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('jobs', function (Blueprint $table) { Schema::create('jobs', function (Blueprint $table) {
@ -45,9 +42,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('jobs'); Schema::dropIfExists('jobs');

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('task_statuses', function (Blueprint $table) { Schema::create('task_statuses', function (Blueprint $table) {
@ -18,9 +15,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('task_statuses'); Schema::dropIfExists('task_statuses');

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('labels', function (Blueprint $table) { Schema::create('labels', function (Blueprint $table) {
@ -19,9 +16,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('labels'); Schema::dropIfExists('labels');

View File

@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('departments', function (Blueprint $table) { Schema::create('departments', function (Blueprint $table) {
@ -17,10 +14,6 @@ return new class extends Migration
$table->timestamps(); $table->timestamps();
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('departments'); Schema::dropIfExists('departments');

View File

@ -6,27 +6,21 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('tasks', function (Blueprint $table) { Schema::create('tasks', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name', 255); $table->string('name', 255);
$table->bigInteger('parent_id');
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('url', 255)->nullable(); $table->string('file', 255)->nullable();
$table->foreignId('status_id')->constrained('task_statuses'); $table->foreignId('status_id')->constrained('task_statuses');
$table->foreignId('department_id')->constrained('departments');
$table->foreignId('created_by_id')->constrained('users'); $table->foreignId('created_by_id')->constrained('users');
$table->bigInteger('assigned_to_id')->nullable();
$table->foreign('assigned_to_id')->references('id')->on('users');
$table->timestamps(); $table->timestamps();
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('tasks'); Schema::dropIfExists('tasks');

View File

@ -6,9 +6,7 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('label_task', function (Blueprint $table) { Schema::create('label_task', function (Blueprint $table) {
@ -18,9 +16,6 @@ return new class extends Migration
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('label_task'); Schema::dropIfExists('label_task');

View File

@ -6,22 +6,18 @@ use Illuminate\Support\Facades\Schema;
return new class extends Migration return new class extends Migration
{ {
/**
* Run the migrations.
*/
public function up(): void public function up(): void
{ {
Schema::create('notes', function (Blueprint $table) { Schema::create('notes', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name', 255); $table->string('name', 255);
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->string('file', 255)->nullable();
$table->foreignId('task_id')->constrained('tasks');
$table->timestamps(); $table->timestamps();
}); });
} }
/**
* Reverse the migrations.
*/
public function down(): void public function down(): void
{ {
Schema::dropIfExists('notes'); Schema::dropIfExists('notes');

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('user_task', function (Blueprint $table) {
$table->foreignId('task_id')->constrained('tasks');
$table->foreignId('user_id')->constrained('users');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('label_task');
}
};

View File

@ -5,6 +5,7 @@ namespace Database\Seeders;
use App\Models\User; use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents; // use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
@ -18,6 +19,7 @@ class DatabaseSeeder extends Seeder
User::factory()->create([ User::factory()->create([
'name' => 'Test User', 'name' => 'Test User',
'email' => 'test@example.com', 'email' => 'test@example.com',
'password' => Hash::make('password'),
]); ]);
} }
} }

View File

@ -2,16 +2,32 @@
namespace Database\Seeders; namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class DepartmentSeeder extends Seeder class DepartmentSeeder extends Seeder
{ {
/**
* Run the database seeds.
*/
public function run(): void public function run(): void
{ {
// DB::table('departments')->insert([
[
'name' => 'отдел Разработки',
'created_at' => Carbon::now(),
],
[
'name' => 'отдел Технического обеспечения',
'created_at' => Carbon::now(),
],
[
'name' => 'отдел Кадров',
'created_at' => Carbon::now(),
],
[
'name' => 'Зарплатный отдел',
'created_at' => Carbon::now(),
],
]);
} }
} }

View File

@ -2,16 +2,32 @@
namespace Database\Seeders; namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LabelSeeder extends Seeder class LabelSeeder extends Seeder
{ {
/**
* Run the database seeds.
*/
public function run(): void public function run(): void
{ {
// DB::table('labels')->insert([
[
'name' => 'разработка',
'created_at' => Carbon::now(),
],
[
'name' => 'приказ № 1000',
'created_at' => Carbon::now(),
],
[
'name' => 'Срочно',
'created_at' => Carbon::now(),
],
[
'name' => 'повышенный приоритет',
'created_at' => Carbon::now(),
],
]);
} }
} }

View File

@ -2,16 +2,35 @@
namespace Database\Seeders; namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class NoteSeeder extends Seeder class NoteSeeder extends Seeder
{ {
/**
* Run the database seeds.
*/
public function run(): void public function run(): void
{ {
// DB::table('notes')->insert([
[
'name' => 'добавлен приказ',
'description' => 'разработка',
'file' => 'file1.pdf',
'task_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'приказ № 1000',
'created_at' => Carbon::now(),
],
[
'name' => 'Срочно',
'created_at' => Carbon::now(),
],
[
'name' => 'повышенный приоритет',
'created_at' => Carbon::now(),
],
]);
} }
} }

View File

@ -0,0 +1,5 @@
@extends('layouts.layout')
@section('content')
asdasdasd
@endsection

View File

@ -1,5 +1,25 @@
@extends('layouts.app') @extends('layouts.layout')
@section('content') @section('content')
asdasdasd <table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">отдел</th>
<th scope="col">Задача</th>
<th scope="col">Статус</th>
<th scope="col">Назначил</th>
<th scope="col">Исполнители</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
</tbody>
</table>
@endsection @endsection

View File

@ -6,8 +6,34 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ToDo</title> <title>ToDo</title>
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
</head> </head>
<body> <body>
@yield('content') <div class="container">
<nav class="navbar navbar-expand-lg bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">ToDo</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link {{ request()->is('admin/tasks*') ? 'active' : '' }}" aria-current="page" href="{{ route('tasks.index') }}">Задачи</a>
</li>
<li class="nav-item">
<a class="nav-link {{ request()->is('admin/task_statuses*') ? 'active' : '' }}" aria-current="page" href="{{ route('task_statuses.index') }}">Статусы</a>
</li>
<li class="nav-item">
<a class="nav-link {{ request()->is('admin/labels*') ? 'active' : '' }}" href="{{ route('labels.index') }}">Метки</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div class="container mt-4">
@yield('content')
</div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,9 @@
<?php <?php
use App\Http\Controllers\LabelController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\TaskController;
use App\Http\Controllers\TaskStatusesController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::get('/', function () { Route::get('/', function () {
@ -17,4 +20,11 @@ Route::middleware('auth')->group(function () {
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
}); });
Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
Route::resources([
'/tasks' => TaskController::class,
'/labels' => LabelController::class,
'/task_statuses' => TaskStatusesController::class,
]);
});
require __DIR__.'/auth.php'; require __DIR__.'/auth.php';

View File

@ -5,6 +5,7 @@ export default defineConfig({
plugins: [ plugins: [
laravel({ laravel({
input: [ input: [
'resources/sass/app.scss',
'resources/css/app.css', 'resources/css/app.css',
'resources/js/app.js', 'resources/js/app.js',
], ],