12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\admin\model\store;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- class StoreDescription extends BaseModel
- {
-
- protected $name = 'store_product_description';
- use ModelTrait;
-
- public static function getDescription($product_id, $type = 0)
- {
- return self::where('product_id', $product_id)->where('type', $type)->value('description');
- }
-
- public static function saveDescription(string $description = '', int $product_id = 0, int $type = 0)
- {
- $description = htmlspecialchars($description);
- if ($product_id) {
- $info = self::where(['product_id' => $product_id, 'type' => $type])->find();
- if ($info) {
- $info->description = $description;
- return $info->save();
- }
- }
- return self::create(compact('description', 'product_id', 'type'));
- }
- }
|