diff --git a/app/Classes/Modules/MilestoneTasks/DataTransferObjects/MilestoneTaskObject.php b/app/Classes/Modules/MilestoneTasks/DataTransferObjects/MilestoneTaskObject.php index 8123802..5b0115e 100644 --- a/app/Classes/Modules/MilestoneTasks/DataTransferObjects/MilestoneTaskObject.php +++ b/app/Classes/Modules/MilestoneTasks/DataTransferObjects/MilestoneTaskObject.php @@ -16,17 +16,17 @@ class MilestoneTaskObject implements DataTransferObject /** @var string */ private $title; - /** @var string */ + /** @var string|null */ private $description; /** * MilestoneTaskObject constructor. * @param int $milestoneId - * @param int $typeId - * @param string $title - * @param string $description + * @param int $typeId + * @param string $title + * @param null|string $description */ - public function __construct(int $milestoneId, int $typeId, string $title, string $description) + public function __construct(int $milestoneId, int $typeId, string $title, ?string $description) { $this->milestoneId = $milestoneId; $this->typeId = $typeId; @@ -59,13 +59,12 @@ class MilestoneTaskObject implements DataTransferObject } /** - * @return string + * @return null|string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } - } \ No newline at end of file diff --git a/app/Http/Resources/CommentResource.php b/app/Http/Resources/CommentResource.php index eb47668..ec65f73 100644 --- a/app/Http/Resources/CommentResource.php +++ b/app/Http/Resources/CommentResource.php @@ -18,7 +18,7 @@ class CommentResource extends JsonResource return [ 'id' => $this->id, 'user' => new UserResource($this), - 'comment' => $this->pivot->comment, + 'comment' => nl2br($this->pivot->comment), 'created_at' => carbon::parse($this->pivot->created_at)->diffForHumans() ]; } diff --git a/app/Models/MilestoneTask.php b/app/Models/MilestoneTask.php index cb16c21..2f8a744 100644 --- a/app/Models/MilestoneTask.php +++ b/app/Models/MilestoneTask.php @@ -3,6 +3,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Spatie\EloquentSortable\Sortable; +use Spatie\EloquentSortable\SortableTrait; use Illuminate\Database\Eloquent\SoftDeletes; @@ -18,9 +20,16 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property string title * @property string description */ -class MilestoneTask extends AbstractModel +class MilestoneTask extends AbstractModel implements Sortable { + use SortableTrait; + + public $sortable = [ + 'order_column_name' => 'order', + 'sort_when_creating' => true, + ]; + use SoftDeletes; @@ -60,6 +69,11 @@ class MilestoneTask extends AbstractModel 'title' => 'required' ]; + public function buildSortQuery() + { + return static::query()->where('milestone_id', $this->milestone_id); + } + /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo **/ @@ -73,7 +87,7 @@ class MilestoneTask extends AbstractModel */ public function taskType(): BelongsTo { - return $this->BelongsTo(ModularType::class, 'type_id', 'id'); + return $this->BelongsTo(ModularType::class, 'type_id', 'id')->withTrashed(); } public function departments(){ diff --git a/database/migrations/2020_05_05_083641_create_milestone_tasks_table.php b/database/migrations/2020_05_05_083641_create_milestone_tasks_table.php index ac78987..0cbe693 100644 --- a/database/migrations/2020_05_05_083641_create_milestone_tasks_table.php +++ b/database/migrations/2020_05_05_083641_create_milestone_tasks_table.php @@ -20,6 +20,7 @@ class CreateMilestoneTasksTable extends Migration $table->unsignedBigInteger('type_id'); $table->string('title'); $table->string('description')->nullable(); + $table->integer('order'); $table->timestamps(); $table->softDeletes(); $table->foreign('milestone_id')->references('id')->on('milestones'); diff --git a/package.json b/package.json index fbca25a..d7e804c 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "select2": "^4.0.13", "vue": "^2.6.10", "vue-avatar": "^2.2.0", + "vue-sortable": "^0.1.3", "vue-template-compiler": "^2.6.10", "vuelidate": "^0.7.4", "vuex": "^3.1.3" diff --git a/resources/assets/vue/app.js b/resources/assets/vue/app.js index 010449c..a7d2fec 100644 --- a/resources/assets/vue/app.js +++ b/resources/assets/vue/app.js @@ -11,6 +11,9 @@ import Avatar from 'vue-avatar'; import Vuelidate from 'vuelidate' import request from './mixins/requestMixin' import crud from './mixins/crudMixin' +import Sortable from 'vue-sortable' + +Vue.use(Sortable) Vue.use(Vuelidate); Vue.component('avatar', Avatar); diff --git a/resources/assets/vue/components/comment/forms/CommentFormComponent.vue b/resources/assets/vue/components/comment/forms/CommentFormComponent.vue index 7f09a3e..3639fc6 100644 --- a/resources/assets/vue/components/comment/forms/CommentFormComponent.vue +++ b/resources/assets/vue/components/comment/forms/CommentFormComponent.vue @@ -1,5 +1,5 @@