Skip to content

Updates for checklists items and Comments #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/tasks.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

175 changes: 175 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions database/migrations/2020_10_27_102330_create_tasks_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
public function up()
{
Schema::create('tasks', function (Blueprint $table) {
Expand All @@ -15,10 +14,12 @@ public function up()
$table->text('description');

$table->tinyInteger('flag')->nullable()->index();

$table->boolean('completed')->index();

$table->dateTime('reminder')->nullable();
$table->smallInteger('status')->nullable();
$table->dateTime('from')->nullable();
$table->dateTime('to')->nullable();
$table->boolean('muted')->default(false);

$table->unsignedInteger('allocated_to')->nullable()->index();
$table->foreign('allocated_to')->references('id')->on('users');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

use LaravelEnso\Migrator\Database\Migration;

return new class extends Migration
{
return new class extends Migration {
protected array $permissions = [
['name' => 'tasks.index', 'description' => 'Show index for tasks', 'is_default' => false],
['name' => 'tasks.create', 'description' => 'Create task', 'is_default' => false],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up()
{
Schema::create('task_checklist_items', function (Blueprint $table) {
$table->id();
$table->foreignId('task_id')->constrained('tasks');
$table->string('name');
$table->unsignedInteger('order_index')->nullable();
$table->boolean('is_completed');
$table->timestamps();
});
}

public function down()
{
Schema::dropIfExists('task_checklist_items');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use LaravelEnso\Migrator\Database\Migration;

return new class extends Migration {
protected array $permissions = [
['name' => 'tasks.checklistItems.store', 'description' => 'Store a new check list', 'is_default' => false],
['name' => 'tasks.checklistItems.update', 'description' => 'Update check list', 'is_default' => false],
['name' => 'tasks.checklistItems.destroy', 'description' => 'Delete check list', 'is_default' => false],
];

protected ?string $parentMenu = '';
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up()
{
Schema::create('task_comments', function (Blueprint $table) {
$table->increments('id');
$table->foreignId('task_id')->constrained();
$table->text('body');

$table->integer('created_by')->unsigned()->nullable()->index();
$table->foreign('created_by')->references('id')->on('users');

$table->integer('updated_by')->unsigned()->nullable();
$table->foreign('updated_by')->references('id')->on('users');

$table->timestamps();
});
}

public function down()
{
Schema::dropIfExists('task_comments');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

use LaravelEnso\Migrator\Database\Migration;

return new class extends Migration {
protected array $permissions = [
['name' => 'tasks.comments.index', 'description' => 'Show index for comments', 'is_default' => false],
['name' => 'tasks.comments.store', 'description' => 'Store a new comment', 'is_default' => false],
['name' => 'tasks.comments.update', 'description' => 'Update comment', 'is_default' => false],
['name' => 'tasks.comments.destroy', 'description' => 'Delete comment', 'is_default' => false],
];
};
3 changes: 3 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@
Route::get('', Index::class)->name('index');

Route::get('users', Users::class)->name('users');

require __DIR__.'/checklistsItems.php';
require __DIR__.'/comments.php';
});
14 changes: 14 additions & 0 deletions routes/checklistsItems.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use Illuminate\Support\Facades\Route;
use LaravelEnso\Tasks\Http\Controllers\Tasks\ChecklistItems\Destroy;
use LaravelEnso\Tasks\Http\Controllers\Tasks\ChecklistItems\Store;
use LaravelEnso\Tasks\Http\Controllers\Tasks\ChecklistItems\Update;

Route::prefix('checklistItems')
->as('checklistItems.')
->group(function () {
Route::post('', Store::class)->name('store');
Route::patch('{checklistItem}', Update::class)->name('update');
Route::delete('{checklistItem}', Destroy::class)->name('destroy');
});
16 changes: 16 additions & 0 deletions routes/comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use App\Http\Controllers\Tasks\Comments\Destroy;
use App\Http\Controllers\Tasks\Comments\Index;
use App\Http\Controllers\Tasks\Comments\Store;
use App\Http\Controllers\Tasks\Comments\Update;
use Illuminate\Support\Facades\Route;

Route::prefix('comments')
->as('comments.')
->group(function () {
Route::get('', Index::class)->name('index');
Route::post('', Store::class)->name('store');
Route::patch('{comment}', Update::class)->name('update');
Route::delete('{comment}', Destroy::class)->name('destroy');
});
3 changes: 3 additions & 0 deletions src/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use LaravelEnso\DynamicMethods\Services\Methods;
use LaravelEnso\Tasks\Commands\SendTaskReminders;
use LaravelEnso\Tasks\DynamicRelations\Tasks;
use LaravelEnso\Tasks\Models\ChecklistItem;
use LaravelEnso\Tasks\Models\Task as Model;
use LaravelEnso\Tasks\Observers\ChecklistItem as ChecklistItemObserver;
use LaravelEnso\Tasks\Observers\Task as Observer;
use LaravelEnso\Users\Models\User;

Expand All @@ -20,6 +22,7 @@ public function boot()
->command()
->relations()
->observers();
ChecklistItem::observe(ChecklistItemObserver::class);
}

private function load(): self
Expand Down
Loading