芝麻web文件管理V1.00
编辑当前文件:/home/forge/stage.sksb.smartcon-survey.com/app/Models/Comment.php
belongsTo(Interview::class); } public function assignedTopics(): BelongsToMany { return $this->belongsToMany(Topic::class, 'comments_topics', 'comment_id', 'topic_id'); } public function topic(): BelongsTo { return $this->belongsTo(Topic::class); } public static function showComment(int $id): void { static::where('id', $id)->update(['show' => 1]); } public static function hideComment(int $id): void { static::where('id', $id)->update(['show' => 2]); } public static function restoreComment(int $id): void { static::where('id', $id)->update(['show' => 0]); } public static function updateComment(int $id, string $comment): void { static::where('id', $id)->update(['comment' => $comment]); } public function scopeWhereInDateRange(Builder $query, array $dateRange): void { $filter = ''; foreach ($dateRange as $key => $month) { [$month, $year] = explode('-', $month); $date = Carbon::create($year, $month); $monthStart = $date->startOfMonth()->format('Y-m-d'); $monthEnd = $date->endOfMonth()->format('Y-m-d'); $filter .= "(comments.created_at >= '$monthStart' AND comments.created_at <= '$monthEnd')"; if ($key < count($dateRange) - 1) { $filter .= ' OR '; } } $query->whereRaw("($filter)"); } }