minor fixes

This commit is contained in:
omair saleh
2020-06-04 12:25:20 +08:00
parent 564191e423
commit f653c9d974
11 changed files with 137 additions and 14 deletions
@@ -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;
}
}
+1 -1
View File
@@ -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()
];
}
+16 -2
View File
@@ -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(){