feat: add article and production modules

This commit is contained in:
2026-08-31 13:16:46 +08:00
parent ac3da246b2
commit 5c586a1a95
334 changed files with 34419 additions and 1 deletions
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace plugin\article\app\dao;
use core\base\BaseDao;
use plugin\article\app\model\Category;
class CategoryDao extends BaseDao
{
protected function setModel(): string
{
return Category::class;
}
protected function getKeywordFields(): array
{
return ['name', 'slug', 'description'];
}
public function selectModel(
array $where,
array|string $field = '*',
int $page = 0,
int $limit = 0,
string $order = '',
array $with = [],
bool $search = false,
?array $withoutScopes = null
): \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Pagination\LengthAwarePaginator|null {
$query = parent::selectModel($where, $field, $page, $limit, $order, $with, $search, $withoutScopes);
if ($query instanceof \Illuminate\Database\Eloquent\Builder) {
$query->withCount(['contents as article_count']);
}
return $query;
}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace plugin\article\app\dao;
use core\base\BaseDao;
use plugin\article\app\model\Content;
class ContentDao extends BaseDao
{
protected function setModel(): string
{
return Content::class;
}
protected function getKeywordFields(): array
{
return ['title', 'slug', 'summary', 'content'];
}
public function get($id, ?array $field = null, ?array $with = ['category', 'tags', 'createds', 'updateds'], string $order = '', ?array $withoutScopes = null): ?\Illuminate\Database\Eloquent\Model
{
return parent::get($id, $field, $with, $order, $withoutScopes);
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace plugin\article\app\dao;
use core\base\BaseDao;
use plugin\article\app\model\Tag;
class TagDao extends BaseDao
{
protected function setModel(): string
{
return Tag::class;
}
protected function getKeywordFields(): array
{
return ['name', 'slug', 'description'];
}
public function selectModel(
array $where,
array|string $field = '*',
int $page = 0,
int $limit = 0,
string $order = '',
array $with = [],
bool $search = false,
?array $withoutScopes = null
): \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Pagination\LengthAwarePaginator|null {
$query = parent::selectModel($where, $field, $page, $limit, $order, $with, $search, $withoutScopes);
if ($query instanceof \Illuminate\Database\Eloquent\Builder) {
$query->withCount(['contents as article_count']);
}
return $query;
}
}