diff --git a/beike/Installer/Lang/en/installer_messages.php b/beike/Installer/Lang/en/installer_messages.php index d5481ad2..71c9e6ef 100644 --- a/beike/Installer/Lang/en/installer_messages.php +++ b/beike/Installer/Lang/en/installer_messages.php @@ -23,8 +23,8 @@ return [ * */ 'welcome' => [ - 'templateTitle' => 'Welcome', - 'title' => 'Laravel Installer', + 'title' => 'Welcome', + 'describe' => 'Welcome to install BeikeShop. Easy Installation and Setup Wizard.', 'message' => 'Easy Installation and Setup Wizard.', 'next' => 'Check Requirements', ], diff --git a/beike/Models/Zone.php b/beike/Models/Zone.php index bea84a75..21aa9641 100644 --- a/beike/Models/Zone.php +++ b/beike/Models/Zone.php @@ -17,6 +17,6 @@ class Zone extends Base { use HasFactory; - protected $fillable = ['name', 'code', 'sort_order', 'status']; + protected $fillable = ['country_id', 'name', 'code', 'sort_order', 'status']; } diff --git a/beike/Repositories/CountryRepo.php b/beike/Repositories/CountryRepo.php index c7693230..9d9e7929 100644 --- a/beike/Repositories/CountryRepo.php +++ b/beike/Repositories/CountryRepo.php @@ -16,6 +16,20 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator; class CountryRepo { + /** + * @param $data + * @return array + */ + private static function handleParams($data) + { + return [ + 'name' => $data['name'] ?? '', + 'code' => $data['code'] ?? '', + 'sort_order' => (int)$data['sort_order'] ?? 0, + 'status' => (bool)$data['status'] ?? 0, + ]; + } + /** * 创建一个country记录 * @param $data @@ -23,6 +37,7 @@ class CountryRepo */ public static function create($data) { + $data = self::handleParams($data); return Country::query()->create($data); } @@ -34,6 +49,7 @@ class CountryRepo */ public static function update($id, $data) { + $data = self::handleParams($data); $country = Country::query()->find($id); if (!$country) { throw new \Exception("国家id {$id} 不存在"); diff --git a/beike/Repositories/ZoneRepo.php b/beike/Repositories/ZoneRepo.php index d90cfc29..156b3ace 100644 --- a/beike/Repositories/ZoneRepo.php +++ b/beike/Repositories/ZoneRepo.php @@ -15,6 +15,21 @@ use Beike\Models\Zone; class ZoneRepo { + /** + * @param $data + * @return array + */ + private static function handleParams($data) + { + return [ + 'country_id' => $data['country_id'] ?? 0, + 'name' => $data['name'] ?? '', + 'code' => $data['code'] ?? '', + 'sort_order' => (int)$data['sort_order'] ?? 0, + 'status' => (bool)$data['status'] ?? 0, + ]; + } + /** * 创建一个zone记录 * @param $data @@ -22,8 +37,8 @@ class ZoneRepo */ public static function create($data) { - $id = Zone::query()->insertGetId($data); - return self::find($id); + $data = self::handleParams($data); + return Zone::query()->create($data); } /** @@ -38,6 +53,7 @@ class ZoneRepo if (!$zone) { throw new \Exception("省份/地区id {$id} 不存在"); } + $data = self::handleParams($data); $zone->update($data); return $zone; }