DESKTOP-70VPDLK\Administrator 7 mēneši atpakaļ
vecāks
revīzija
7ad7967990
2 mainītis faili ar 73 papildinājumiem un 2 dzēšanām
  1. 59 1
      app/Models/TableNumber.php
  2. 14 1
      app/Servers/ShopServer.php

+ 59 - 1
app/Models/TableNumber.php

@@ -2,18 +2,76 @@
 
 namespace App\Models;
 
+use DateTimeInterface;
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 use Illuminate\Database\Eloquent\Model;
 
+
 /**
  * App\Models\TableNumber
  *
+ * @property int $id
+ * @property int $shop_id 店铺ID
+ * @property int $number 桌号
+ * @property string $table_code 桌号码
+ * @property int|null $status 状态
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @property string|null $title 标题
+ * @property int|null $is_del
  * @method static \Illuminate\Database\Eloquent\Builder|TableNumber newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|TableNumber newQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|TableNumber query()
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereIsDel($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereNumber($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereShopId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereStatus($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereTableCode($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereTitle($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|TableNumber whereUpdatedAt($value)
  * @mixin \Eloquent
  */
 class TableNumber extends Model
 {
-    use HasFactory;
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected $table = 'table_number';
+
+    /**
+     * The primary key associated with the table.
+     *
+     * @var string
+     */
+    protected $primaryKey = 'id';
+
+    /**
+     * Indicates if the model should be timestamped.
+     *
+     * @var bool
+     */
+    public $timestamps = true;
+
+
+    /**
+     * 不能被批量赋值的属性
+     *
+     * @var array
+     */
+    protected $guarded = [ 'id', 'updated_at', 'created_at'];
+
+    /**
+     * 为数组 / JSON 序列化准备日期。
+     *
+     * @param DateTimeInterface $date
+     * @return string
+     */
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
+    }
 }

+ 14 - 1
app/Servers/ShopServer.php

@@ -6,6 +6,7 @@ namespace App\Servers;
 
 
 use App\Models\Main\MainShop;
+use App\Models\TableNumber;
 use Illuminate\Support\Facades\DB;
 
 /**
@@ -40,7 +41,19 @@ class ShopServer
      */
     function getShopInfo($shop_id){
          //$status 1正常 2闭店
-        return MainShop::where('id',$shop_id)->select(['id','shop_name','status','shop_logo','shop_phone','address'])->first();
+        return MainShop::where('id',$shop_id)->select(['id','shop_name','status','shop_logo','shop_phone','address','city_name'])->first();
+    }
+
+
+    /**
+     * 获取桌号信息
+     * @param $shop_id
+     * @param $number
+     * @return TableNumber|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|object|null
+     */
+    function getTableInfo($shop_id,$number){
+        //$status 1正常 2闭店
+        return TableNumber::where('shop_id',$shop_id)->where('number',$number)->select(['id','number','title','status'])->first();
     }