示例#1
0
文件: Eloquent.php 项目: emayk/ics
 /**
  * Generate Data Warehouse Jika Belum Ada
  *
  * @return bool|int|mixed
  */
 public function generateWarehouse()
 {
     /*
      * Warehouse Memerlukan Category
      *
      * maka sebelumnya dibuatkan dl
      * - Warehouse Category
      * - City
      * -
      */
     if ($this->emptyWarehouse()) {
         DB::beginTransaction();
         $catwh = Warehousecategory::create(array('id' => 1, 'name' => 'Pusat', 'info' => 'Gudang Utama'));
         $ptype = 'Emayk\\Ics\\Repo\\Locations\\Locations';
         $uid = $this->uid();
         $fake = new AbstractGenerate();
         $fake = $fake->getFake();
         $uuid = $fake->uuid;
         Locations::insert(array(array('id' => 1, 'name' => 'Indonesia', 'level' => 1, 'parent_id' => 0, 'parent_type' => $ptype, 'uuid' => $uuid, 'createby_id' => $uid, 'lastupdateby_id' => $uid), array('id' => 2, 'name' => 'Jawa Barat', 'level' => 2, 'parent_id' => 1, 'parent_type' => $ptype, 'uuid' => $uuid, 'createby_id' => $uid, 'lastupdateby_id' => $uid), array('id' => 3, 'name' => 'Bandung', 'level' => 3, 'parent_id' => 2, 'parent_type' => $ptype, 'uuid' => $uuid, 'createby_id' => $uid, 'lastupdateby_id' => $uid)));
         $cityId = 3;
         $wh = Warehouse::create(array('id' => 1, 'name' => 'Gudang Utama', 'address' => $fake->streetAddress, 'city_id' => $cityId, 'cat_id' => $catwh->id, 'uuid' => $uuid, 'createby_id' => $uid, 'lastupdateby_id' => $uid));
         DB::commit();
         return $wh->id;
     }
     return false;
 }
示例#2
0
文件: Warehouse.php 项目: emayk/ics
 /**
  * @return int|mixed
  */
 public static function getDefaultWarehouseIdOrCreate()
 {
     $id = static::Name(static::$defaultName)->pluck('id');
     if (null == $id) {
         /* Create Record */
         $countryId = Locations::getIdsDefaultCountryOrCreate();
         $provinceId = Locations::getIdsDefaultProvinceOrCreate($countryId);
         $cityId = Locations::getIdsDefaultCityOrCreate($provinceId);
         $catId = Warehousecategory::getIdDefaultWarehouseCategoryOrCreate();
         $wh = static::create(static::getFake()->getWarehouse()->createWarehouse(static::$defaultName, $cityId, $catId));
         $id = $wh->id;
     }
     return $id;
 }