first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace App\FormModel\admin\articles;
class ArticlesModel
{
public function edit()
{
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\FormModel\admin\articles;
class BaseModify
{
protected array $attributes = [];
public function setAttributes(array $modifyData): static
{
$this->attributes = $modifyData;
return $this;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\FormModel\admin\articles;
use App\FormModel\admin\articles\trait\ModifyForUpdate;
class ModifyModel extends BaseModify
{
use ModifyForUpdate;
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\FormModel\admin\articles\module;
class BaseModule
{
protected array $attributes = [];
public function setAttributes()
{
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\FormModel\admin\articles\module;
class ShowsModel
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace App\FormModel\admin\articles\module;
class StreetModel extends BaseModule
{
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\FormModel\admin\articles\trait;
use App\Model\AppArticle;
trait ModifyForUpdate
{
protected array $canUpdateFields = ['title', 'cover', 'images', 'brand', 'location'];
public function update()
{
$query = AppArticle::where(['aid' => $this->attributes['aid']])->first();
foreach ($this->canUpdateFields as $field) {
$val = $this->attributes[$field] ?? null;
if ($val !== null) {
$query->{$field} = $this->attributes[$field];
}
}
$query->save();
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\FormModel\admin\news;
use App\Model\AppNews;
class NewsFormModel
{
private array $attributes = [];
public function setAttributes(array $attr, $allowProp = [])
{
if (!$allowProp) {
$this->attributes = $attr;
}
foreach($allowProp as $prop) {
if (isset($attr[$prop])) {
$this->attributes[$prop] = $attr[$prop];
}
}
return $this;
}
public function insert()
{
$model = new AppNews();
$model->setRawAttributes($this->attributes);
$model->save();
}
public function update()
{
$model = AppNews::find($this->attributes['id']);
$model->title = $this->attributes['title'];
$model->keywords = $this->attributes['keywords'];
$model->description = $this->attributes['description'];
$model->cover = $this->attributes['cover'];
$model->content = $this->attributes['content'];
$model->save();
}
}