/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $names = ['Đông', 'Tây', 'Nam', 'Bắc', 'Đông Nam', 'Đông Bắc', 'Tây Nam', 'Tây Bắc'];
     foreach ($names as $key => $value) {
         $incense_type = Incense_type::create(['key' => Common::createKeyURL($value), 'name' => $value, 'priority' => $key, 'active' => 1, 'created_by' => 'vankhoeseed', 'updated_by' => 'vankhoeseed']);
     }
 }
 public function postPost(Request $request)
 {
     $input = $request->all();
     $rules = ['title' => ['max:20', 'required'], 'content' => ['min:10', 'required']];
     $validator = Validator::make($input, $rules);
     $returnInf = [];
     if ($validator->fails()) {
         $messages = $validator->messages();
         foreach ($array_dot($messages->toArray) as $value) {
             array_push($returnInf, $value);
         }
         Session::flash('operationResult', 'am-alert-warning');
         Session::flash('returnInf', $returnInf);
         return redirect()->back()->withInput(Request::flash());
     } else {
         $article = Article::create(['title' => $input['title'], 'content' => Common::encodeTopicContent($input['content']), 'node_id' => $input['node_id'], 'user_id' => $input['user_id']]);
         if ($article->id > 0) {
             array_push($returnInf, '发帖成功');
             Session::flash('operationResult', 'am-alert-success');
             Node::find($input['node_id'])->increment('article_count');
             User::find($input['user_id'])->increment('article_count');
         } else {
             array_push($returnInf, '我们的数据库出问题啦,请稍后再试=。=');
             Session::flash('operationResult', 'am-alert-warning');
         }
     }
     Session::flash('returnInf', $returnInf);
     return redirect()->back();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     $articleCategories = ['Thị trường nhà đất', 'Dự án căn hộ', 'Đầu tư căn hộ', 'Lời khuyên'];
     //, 'Vị trí bài viết', 'Slideshow chính', 'Trang chủ', 'Slideshow footer'];
     $articleCategoryPositionArticles = null;
     foreach ($articleCategories as $key => $value) {
         $articleCategory = ArticleCategory::create(['key' => Common::createKeyURL($value), 'parent_id' => is_null($articleCategoryPositionArticles) ? 0 : $articleCategoryPositionArticles->id, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoektcn', 'updated_by' => 'vankhoektcn']);
         ArticleCategoryTranslation::create(['article_category_id' => $articleCategory->id, 'locale' => 'vi', 'name' => $value, 'summary' => $value, 'meta_description' => $value, 'meta_keywords' => $value]);
         if ($value == 'Vị trí bài viết') {
             $articleCategoryPositionArticles = $articleCategory;
         }
     }
     $articles = ['Giới Thiệu', 'Tuyển Dụng', 'Tài Khoản Giao Dịch'];
     foreach ($articles as $key => $value) {
         $article = Article::create(['key' => Common::createKeyURL($value), 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoektcn', 'updated_by' => 'vankhoektcn']);
         ArticleTranslation::create(['article_id' => $article->id, 'locale' => 'vi', 'name' => $value, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->realText($maxNbChars = 1000, $indexSize = 2), 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
     }
     $categories = ArticleCategory::where('parent_id', '=', 0)->lists('id');
     $categories2 = ArticleCategory::where('parent_id', '<>', 0)->lists('id');
     for ($i = 0; $i < 3; $i++) {
         $name = $generator->sentence($nbWords = 6);
         $key = Common::createKeyURL($name);
         $article = Article::create(['key' => $key, 'priority' => $i, 'is_publish' => 1, 'created_by' => 'vankhoektcn', 'updated_by' => 'vankhoektcn']);
         ArticleTranslation::create(['article_id' => $article->id, 'locale' => 'vi', 'name' => $name, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->text, 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
         Attachment::create(['entry_id' => $article->id, 'table_name' => 'articles', 'path' => '/uploads/notfound.jpg', 'priority' => 0, 'is_publish' => 1]);
         $article->categories()->attach($categories->random());
         //$article->categories()->attach($categories2->random());
     }
 }
 public static function format($obj)
 {
     $data = [];
     foreach ($obj as $notification) {
         $text = "";
         $link = "";
         $icon = "";
         $more = json_decode($notification->more);
         switch ($notification->type) {
             case 'USER_UPDATE_BY_ADMIN':
                 $text = "Your personal details are changed by " . User::find($more->admin_id)->info()->pluck('names') . " (administrator)";
                 $icon = 'user';
                 $link = asset('/profile');
                 break;
             case 'CREATE_EVENT':
                 $text = "You have new event from" . User::find($more->admin_id)->info()->pluck('names') . " (administrator). <br><b>Start:</b> {$more->start} <br><b>End:</b> {$more->end} <br> Please specify if you accept it.";
                 $icon = 'calendar';
                 $link = asset('/rosters');
                 break;
             case 'UPDATE_EVENT':
                 $text = "You have updated event <i>{$more->title}</i> from" . User::find($more->admin_id)->info()->pluck('names') . " (administrator). <br><b>Start:</b> {$more->start} <br><b>End:</b> {$more->end} ";
                 $icon = 'calendar';
                 $link = asset('/rosters');
                 break;
             default:
                 $text = $notification->type;
                 break;
         }
         array_push($data, ['text' => $text, 'icon' => $icon, 'date' => Common::timeAgo($notification->created_at), 'id' => $notification->id, 'is_read' => $notification->is_read, 'link' => $link]);
     }
     return $data;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     $articleCategories = ['Thông tin', 'Bài viết nỗi bật'];
     foreach ($articleCategories as $key => $value) {
         $articleCategory = ArticleCategory::create(['key' => Common::createKeyURL($value), 'parent_id' => 0, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         ArticleCategoryTranslation::create(['article_category_id' => $articleCategory->id, 'locale' => 'vi', 'name' => $value, 'summary' => $value, 'meta_description' => $value, 'meta_keywords' => $value]);
     }
     $articles = ['Giới thiệu', 'Dịch vụ của chúng tôi', 'Tại sao chọn chúng tôi'];
     foreach ($articles as $key => $item) {
         $article = Article::create(['key' => Common::createKeyURL($item), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         ArticleTranslation::create(['article_id' => $article->id, 'locale' => 'vi', 'name' => $item, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->text, 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
         Attachment::create(['entry_id' => $article->id, 'table_name' => 'articles', 'path' => '/uploads/notfound.jpg', 'priority' => 0, 'is_publish' => 1]);
     }
     // BÀI VIẾT THÔNG TIN
     $articleCategory = ArticleCategory::findByKey('thong-tin')->first()->id;
     if (!is_null($articleCategory) && count($articleCategory) > 0) {
         for ($i = 0; $i < 10; $i++) {
             $name = $generator->sentence($nbWords = 6);
             $article = Article::create(['key' => Common::createKeyURL($name), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
             ArticleTranslation::create(['article_id' => $article->id, 'locale' => 'vi', 'name' => $name, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->text, 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
             /*
             Attachment::create([
             	'entry_id' => $article->id,
             	'table_name' => 'articles',
             	//'path' => $generator->imageUrl($width = 780, $height = 546),
             	'path' => '/uploads/notfound.jpg',
             	'priority' => 0,
             	'is_publish' => 1
             ]);
             */
             $article->categories()->attach($articleCategory);
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $subjects = ['Toán', 'Lý', 'Hoá', 'Sinh', 'Văn', 'Sử', 'Địa', 'Tiếng Anh', 'Tiếng Pháp', 'Tiếng Nga', 'Tiếng Nhật', 'Tiếng Đức', 'Tin Học'];
     foreach ($subjects as $key => $value) {
         $subject = Subject::create(['key' => Common::createKeyURL($value), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
         SubjectTranslation::create(['subject_id' => $subject->id, 'locale' => 'vi', 'name' => $value]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     $name = 'Giới thiệu';
     $article = Article::create(['key' => Common::createKeyURL($name), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
     ArticleTranslation::create(['article_id' => $article->id, 'locale' => 'vi', 'name' => $name, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->text, 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
     Attachment::create(['entry_id' => $article->id, 'table_name' => 'articles', 'path' => '/uploads/notfound.jpg', 'priority' => 0, 'is_publish' => 1]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $colors = ['Trắng', 'Đen', 'Xanh', 'Đỏ', 'Tím', 'Vàng'];
     foreach ($colors as $key => $color) {
         $productColor = ProductColor::create(['key' => Common::createKeyURL($color), 'parent_id' => 0, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         ProductColorTranslation::create(['product_color_id' => $productColor->id, 'locale' => 'vi', 'name' => $color, 'summary' => $color]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $provinces = ['Hồ Chí Minh', 'Hà Nội'];
     foreach ($provinces as $key => $value) {
         $province = Province::create(['key' => Common::createKeyURL($value), 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
         ProvinceTranslation::create(['province_id' => $province->id, 'locale' => 'vi', 'name' => $value, 'meta_description' => 'Bán căn hộ ' . $value . ', sang nhượng căn hộ ' . $value . ', cho thuê căn hộ ' . $value, 'meta_keywords' => 'Bán căn hộ ' . $value . ', sang nhượng căn hộ ' . $value . ', cho thuê căn hộ ' . $value]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $categories = ['Banner Chính', 'Khách Hàng', 'Banner Social'];
     foreach ($categories as $key => $category) {
         $navigationCategory = NavigationCategory::create(['key' => Common::createKeyURL($category), 'parent_id' => 0, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         NavigationCategoryTranslation::create(['navigation_category_id' => $navigationCategory->id, 'locale' => 'vi', 'name' => $category, 'summary' => $category]);
     }
 }
 public function update($id, Request $request)
 {
     $event = Availability::find($id);
     $event->start_time = Common::formatDateTimeForSQL($request->input('new_time_start'));
     $event->end_time = Common::formatDateTimeForSQL($request->input('new_time_end'));
     $event->save();
     return response()->json(['msg' => 'Time updated'], 200);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $provinces = ['Hồ Chí Minh', 'Hà Nội'];
     foreach ($provinces as $key => $value) {
         $province = Province::create(['key' => Common::createKeyURL($value), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
         ProvinceTranslation::create(['province_id' => $province->id, 'locale' => 'vi', 'name' => $value]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     $value = 'Banner Chính 1';
     $navigation = Navigation::create(['key' => Common::createKeyURL($value), 'navigation_category_id' => 1, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
     NavigationTranslation::create(['navigation_id' => $navigation->id, 'locale' => 'vi', 'name' => $value, 'summary' => $value]);
     Attachment::create(['entry_id' => $navigation->id, 'table_name' => 'navigations', 'path' => $generator->imageUrl($width = 1269, $height = 820), 'priority' => 0, 'is_publish' => 1]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $names = ['Thỏa thuận', 'Triệu', 'Tỷ', 'Trăm nghìn/m2', 'Triệu/m2'];
     $from = [0, 1000000, 1000000000, 100000, 1000000];
     foreach ($names as $key => $value) {
         $project_type = Price_type::create(['key' => Common::createKeyURL($value), 'name' => $value, 'value' => $from[$key], 'priority' => $key, 'active' => 1, 'created_by' => 'vankhoeseed', 'updated_by' => 'vankhoeseed']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $names = ['Thỏa thuận', '< 500 triệu', '500 - 800 triệu', '800 triệu - 1 tỷ', '1 - 2 tỷ', '2 - 3 tỷ', '3 - 5 tỷ', '5 - 7 tỷ', '7 - 10 tỷ', '10 - 20 tỷ', '20 - 30 tỷ', '> 30 tỷ'];
     $from = [0, 0, 500000000, 800000000, 1000000000, 2000000000, 3000000000, 5000000000, 7000000000, 10000000000, 20000000000, 30000000000];
     $to = [0, 499999999, 800000000, 1000000000, 2000000000, 3000000000, 5000000000, 7000000000, 10000000000, 20000000000, 30000000000, 100000000000];
     foreach ($names as $key => $value) {
         $project_type = Price_range::create(['key' => Common::createKeyURL($value), 'name' => $value, 'from' => $from[$key], 'to' => $to[$key], 'priority' => $key, 'active' => 1, 'created_by' => 'vankhoeseed', 'updated_by' => 'vankhoeseed']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $names = ['Chưa xác định', '<= 30 m2', '30 - 50 m2', '50 - 80 m2', '80 - 100 m2', '100 - 150 m2', '150 - 200 m2', '200 - 250 m2', '250 - 300 m2', '300 - 500 m2', '>= 500 m2'];
     $from = [0, 0, 30, 50, 80, 100, 150, 200, 250, 300, 500];
     $to = [0, 29, 50, 80, 100, 150, 200, 250, 300, 500, 1000];
     foreach ($names as $key => $value) {
         $project_type = Area_range::create(['key' => Common::createKeyURL($value), 'name' => $value, 'from' => $from[$key], 'to' => $to[$key], 'priority' => $key, 'active' => 1, 'created_by' => 'vankhoeseed', 'updated_by' => 'vankhoeseed']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $navigation_category_names = ['Banner trang chủ', 'Khách hàng tiêu biểu', 'Banner email server', 'Banner Máy chủ', 'Banner Hosting', 'Banner Tên Miền', 'Banner CDN', 'Banner Website', 'Banner Landing Page'];
     $navigation_category_summarys = ['Mô tả banner trang chủ', 'Chúng tôi có kinh nghiệm làm việc với các đối tác lớn', 'Mô tả banner email server', 'Mô tả banner Máy chủ', 'Mô tả banner Hosting', 'Mô tả banner Tên Miền', 'Mô tả banner CDN', 'Mô tả banner Website', 'Banner Landing Page'];
     foreach ($navigation_category_names as $key => $value) {
         $navigationCategory = NavigationCategory::create(['key' => Common::createKeyURL($value), 'parent_id' => 0, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'vankhoektcn', 'updated_by' => 'vankhoektcn']);
         NavigationCategoryTranslation::create(['navigation_category_id' => $navigationCategory->id, 'locale' => 'vi', 'name' => $value, 'summary' => $navigation_category_summarys[$key]]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $project_types = ['Căn hộ chung cư', 'Khu biệt thự', 'Cao ốc văn phòng', 'Khu thương mại', 'Khu dân cư', 'Nhà ở xã hội', 'Khu đô thị mới'];
     $project_types_meta_description = ['Căn hộ chung cư', 'Khu biệt thự', 'Cao ốc văn phòng', 'Khu thương mại', 'Khu dân cư', 'Nhà ở xã hội', 'Khu đô thị mới'];
     $project_types_meta_keywords = ['Căn hộ chung cư', 'Khu biệt thự', 'Cao ốc văn phòng', 'Khu thương mại', 'Khu dân cư', 'Nhà ở xã hội', 'Khu đô thị mới'];
     foreach ($project_types as $key => $value) {
         $project_type = Project_type::create(['key' => Common::createKeyURL($value), 'name' => $value, 'priority' => $key, 'meta_description' => $project_types_meta_description[$key], 'meta_keywords' => $project_types_meta_keywords[$key], 'active' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $product_types = ['Căn hộ bán', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     $product_types_meta_description = ['Bán căn hộ. Căn hộ chính chủ, sổ hồng, căn hộ chất lượng, cập nhật thông tin mua bán căn hộ mới nhất trên khắp các tỉnh thành Hồ Chí Minh, Hà Nội, Đà nẵng, Bình Dương', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     $product_types_meta_keywords = ['Bán căn hộ, bán căn hộ quận 2, căn hộ chính chủ, căn hộ sổ hồng.', 'Căn hộ sang nhượng', 'Căn hộ cho thuê'];
     foreach ($product_types as $key => $value) {
         $product_type = Product_type::create(['key' => Common::createKeyURL($value), 'name' => $value, 'priority' => $key, 'meta_description' => $product_types_meta_description[$key], 'meta_keywords' => $product_types_meta_keywords[$key], 'active' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     for ($i = 0; $i < 10; $i++) {
         $name = $generator->sentence($nbWords = 6);
         $product = Product::create(['key' => Common::createKeyURL($name), 'code' => $generator->unique()->randomDigit, 'producer_id' => 0, 'origin' => $generator->sentence($nbWords = 2), 'unit' => $generator->word, 'price' => $generator->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL), 'discount' => $generator->numberBetween($min = 0, $max = 100), 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         ProductTranslation::create(['product_id' => $product->id, 'locale' => 'vi', 'name' => $name, 'summary' => $generator->text($maxNbChars = 200), 'content' => $generator->text, 'meta_description' => $generator->text($maxNbChars = 200), 'meta_keywords' => $generator->text($maxNbChars = 200)]);
         Attachment::create(['entry_id' => $product->id, 'table_name' => 'products', 'path' => '/uploads/notfound.jpg', 'priority' => 0, 'is_publish' => 1]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $projectCategories = ['Dự án nổi bật', 'Dự án mới nhất', 'Căn hộ sang nhượng', "Căn hộ cho thuê", 'Vị trí dự án', 'Slideshow chính', 'Trang chủ', 'Slideshow footer'];
     $projectCategoryPositionProjects = null;
     foreach ($projectCategories as $key => $value) {
         $projectCategory = ProjectCategory::create(['key' => Common::createKeyURL($value), 'parent_id' => is_null($projectCategoryPositionProjects) ? 0 : $projectCategoryPositionProjects->id, 'name' => $value, 'summary' => $value, 'meta_description' => $value, 'meta_keywords' => $value, 'priority' => 0, 'active' => 1, 'created_by' => 'vankhoektcn', 'updated_by' => 'vankhoektcn']);
         if ($value == 'Vị trí dự án') {
             $projectCategoryPositionProjects = $projectCategory;
         }
     }
 }
 public static function createKeyURL($string)
 {
     $string = Common::stripUnicode($string);
     $string = str_replace("/", "-", $string);
     $string = str_replace(" ", "-", $string);
     // Replaces all spaces with hyphens.
     $string = preg_replace('/[^A-Za-z0-9\\-]/', '', $string);
     // Removes special chars.
     $string = preg_replace('/-+/', '-', $string);
     // Replaces multiple hyphens with single one.
     return strtolower($string);
 }
 public function createContact(Request $request)
 {
     $validator = Validator::make($request->get('Contact'), Contact::$rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         $contact = new Contact();
         $contact->full_name = $request->input('Contact.full_name');
         $contact->email = $request->input('Contact.email');
         $contact->phone = $request->input('Contact.phone');
         $contact->subject = $request->input('Contact.subject');
         $contact->content = $request->input('Contact.content');
         //save data contact
         $contact->save();
         // send email
         $common = new Common();
         $config = new Config();
         $common->sendEmail('frontend.emails.contact', $data = ['contact' => $contact], $to = $config->getValueByKey('address_received_mail'), $toName = $contact->full_name, $subject = $contact->subject, $cc = $contact->email, $replyTo = $contact->email);
         //return redirect(route('contact'))->with('contact-status', 'Nội dung liên hệ của quý khách đã được gửi đến ban quản trị. Chúng tôi sẽ phản hồi quý khách trong thời gian sớm nhất. Xin cảm ơn!');
         return 1;
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $districts = ['Quận 1', 'Quận 2', 'Quận 3', 'Quận 4', 'Quận 5', 'Quận 6', 'Quận 7', 'Quận 8', 'Quận 9', 'Quận Thủ Đức', 'Quận Bình Thạnh', 'Quận Phú Nhuận', 'Quận Tân Phú', 'Quận Tân Bình', 'Huyện Hóc Môn', 'Huyện Bình Chánh', 'Huyện Nhà Bè', 'Huyện Củ Chi', 'Huyện Cần Giờ'];
     $provinces = Province::where('is_publish', 1)->orderBy('priority')->take(1)->get();
     $province_id = 1;
     if (is_null($provinces) || $provinces->count() == 0) {
         $province_id = $provinces[0]->id;
     }
     foreach ($districts as $key => $value) {
         $district = district::create(['key' => Common::createKeyURL($value), 'province_id' => $province_id, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
         DistrictTranslation::create(['district_id' => $district->id, 'locale' => 'vi', 'name' => $value, 'meta_description' => 'Bán căn hộ ' . $value . ', sang nhượng căn hộ ' . $value . ', cho thuê căn hộ ' . $value, 'meta_keywords' => 'Bán căn hộ ' . $value . ', sang nhượng căn hộ ' . $value . ', cho thuê căn hộ ' . $value]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // QUẬN 1
     $wards_quan1 = ['Bến Nghé', 'Bến Thành', 'Cầu Kho', 'Cầu Ông Lãnh', 'Cô Giang', 'Đa Kao', 'Nguyễn Cư Trinh', 'Nguyễn Thái Bình', 'Phạm Ngũ Lão', 'Tân Định'];
     $quan1 = District::where('key', 'quan-1')->get();
     $quan1_id = 1;
     $quan1_name = 'Quận 1';
     if (is_null($quan1) || $quan1->count() == 0) {
         $quan1_id = $quan1_id[0]->id;
         $quan1_name = $quan1_id[0]->name;
     }
     foreach ($wards_quan1 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan1_name), 'name' => $value, 'district_id' => $quan1_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan1_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan1_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan1_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan1_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan1_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan1_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN 2
     $wards_quan2 = ['An Khánh', 'An Lợi Đông', 'An Phú', 'Bình An', 'Bình Khánh', 'Bình Trưng Tây', 'Bình Trưng Đông', 'Cát Lái', 'Thạnh Mỹ Lợi', 'Thảo Điền', 'Thủ Thiêm'];
     $quan2 = District::where('key', 'quan-2')->get();
     $quan2_id = 2;
     $quan2_name = 'Quận 2';
     if (is_null($quan2) || $quan2->count() == 0) {
         $quan2_id = $quan2_id[0]->id;
         $quan2_name = $quan2_id[0]->name;
     }
     foreach ($wards_quan2 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan2_name), 'name' => $value, 'district_id' => $quan2_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan2_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan2_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN 9
     $wards_quan9 = ['Hiệp Phú', 'Long Bình', 'Long Phước', 'Long Thạnh Mỹ', 'Long Trường', 'Phú Hữu', 'Phước Bình', 'Phước Long A', 'Phước Long B', 'Tân Phú', 'Tăng Nhơn Phú A', 'Tăng Nhơn Phú B', 'Trường Thạnh'];
     $quan9 = District::where('key', 'quan-9')->get();
     $quan9_id = 9;
     $quan9_name = 'Quận 9';
     if (is_null($quan9) || $quan9->count() == 0) {
         $quan9_id = $quan9_id[0]->id;
         $quan9_name = $quan9_id[0]->name;
     }
     foreach ($wards_quan9 as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan9_name), 'name' => $value, 'district_id' => $quan9_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan9_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan9_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan9_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan9_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan9_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan9_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
     // QUẬN Thủ Đức
     $wards_quan_thu_duc = ['Bình Chiểu', 'Bình Thọ', 'Hiệp Bình Chánh', 'Hiệp Bình Phước', 'Linh Chiểu', 'Linh Đông', 'Linh Tây', 'Linh Trung', 'Linh Xuân', 'Tam Bình', 'Tam Phú', 'Trường Thọ'];
     $quan_thu_duc = District::where('key', 'quan-thu-duc')->get();
     $quan_thu_duc_id = 10;
     $quan_thu_duc_name = 'Quận Thủ Đức';
     if (is_null($quan_thu_duc) || $quan_thu_duc->count() == 0) {
         $quan_thu_duc_id = $quan_thu_duc_id[0]->id;
         $quan_thu_duc_name = $quan_thu_duc_id[0]->name;
     }
     foreach ($wards_quan_thu_duc as $key => $value) {
         $ward = Ward::create(['key' => Common::createKeyURL($value . ' ' . $quan_thu_duc_name), 'name' => $value, 'district_id' => $quan_thu_duc_id, 'meta_description' => 'Bán căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan_thu_duc_name, 'meta_keywords' => 'Bán căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', sang nhượng căn hộ phường ' . $value . ' ' . $quan_thu_duc_name . ', cho thuê căn hộ phường ' . $value . ' ' . $quan_thu_duc_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // $streets_quan2 = ['1', '10', '10F', '11', '12', '13', '14', '15', '16', '17', '18', '19', '2', '20', '21', '21A', '22', '23', '24', '25', '26', '27', '28', '29', '3', '30', '30B', '31', '31A', '31B', '31C', '31D', '31E', '31F', '32', '33', '34', '35', '36', '37A', '38', '39', '4', '40', '41', '41B', '42', '43', '44', '45', '46', '47', '49', '5', '50', '51', '52', '53', '54', '55', '56', '58', '59', '6', '60', '61', '62', '63', '64', '65', '66', '68', '7', '7A', '7C', '8', '80', '83', '8A', '8G', '8K', '9', '95', 'A2', 'An Phú', 'An Phú Đông 27', 'An Trang', 'B', 'Bát Nàn', 'Bình An', 'Bình Trưng', 'Bùi Tá Hán', 'Cao Đức Lân', 'Đại Lộ Đông Tây', 'Đàm Văn Lễ', 'Đặng Hữu Phổ', 'Đặng Như Mai', 'Đặng Tiến Đông', 'Đỗ Pháp Thuận', 'Đỗ Quang', 'Đỗ Xuân Hợp', 'Đoàn Hữu Trưng', 'Đông Hưng Thuận 6', 'Đồng Quốc Bình', 'Đồng Văn Cống', 'Dư Hàng Kênh', 'Đường A', 'Đường C', 'Dương Văn An', 'G1', 'Giang Văn Minh', 'H', 'Hà Quang', 'Hàn Giang', 'Hậu Lân', 'Hiệp Thành 13', 'Hương lộ 62', 'K', 'KP3', 'Lâm Quang Ký', 'Lê Đình Quản', 'Lê Đức Thọ', 'Lê Hiến Mai', 'Lê Hồng Phong', 'Lê Hữu Kiều', 'Lê Phụng Hiểu', 'Lê Thước', 'Lê Văn Miến', 'Lê Văn Thịnh', 'Lộc Hòa', 'Lương Định Của', 'Lý Ông Trọng', 'Mai Chí Thọ', 'Mương Khai', 'Ngô Quang Huy', 'Nguyễn Án', 'Nguyễn Bá Huân', 'Nguyễn Bá Lân', 'Nguyễn Cừ', 'Nguyễn Đăng Đạo', 'Nguyễn Đăng Giai', 'Nguyễn Địa Lô', 'Nguyễn Đôn Tiết', 'Nguyễn Duy Hiệu', 'Nguyễn Duy Trinh', 'Nguyễn Hoàng', 'Nguyễn Hương', 'Nguyễn Huy Chương', 'Nguyễn Khanh', 'Nguyễn Khoa Đăng', 'Nguyễn Lương Dĩ', 'Nguyễn Quang Bật', 'Nguyễn Quý Cảnh', 'Nguyễn Quý Đức', 'Nguyễn Thanh Sơn', 'Nguyễn Thị Định', 'Nguyễn Trọng Quân', 'Nguyễn Trung Nguyệt', 'Nguyễn Tư Nghiêm', 'Nguyễn Tuyển', 'Nguyễn Ư Dĩ', 'Nguyễn Văn Giáp', 'Nguyễn Văn Hưởng', 'Nguyễn Văn Kỉnh', 'Phạm Công Trứ', 'Phạm Đôn Lễ', 'Phạm Hy Lượng', 'Phạm Thận Duật', 'Phan Bá Vành', 'Phan Văn Đáng', 'Quách Giai', 'Quốc Hương', 'Quốc lộ 1A', 'Song Hành', 'Sử Hy Nhan', 'Tạ Hiện', 'Tân Chánh Hiệp 16', 'Tân Lập 2', 'Tân Thới Hiệp 10', 'Thái Thuận', 'Thân Văn Nhiếp', 'Thạnh Lộc 27', 'Thạnh Mỹ Bắc', 'Thạnh Mỹ Lợi', 'Thạnh Mỹ Nam', 'Thạnh Xuân 13', 'Thạnh Xuân 21', 'Thảo Điền', 'Thích Mật Thể', 'Tỉnh Lộ 10', 'Tỉnh lộ 25B', 'Tống Hữu Định', 'Trại Gà', 'Trần Lưu', 'Trần Lựu', 'Trần Não', 'Trần Ngọc Diện', 'Trần Quang Đạo', 'Trích Sài', 'Trịnh Khắc Lập', 'Trúc Đường', 'Trương Gia Mô', 'Trương Văn Bang', 'Trương Văn Đa', 'Vạn Kiếp', 'Vành Đai 2', 'Vành Đai Đông', 'Võ Trường Toản', 'Võ Văn Kiệt', 'Vũ Phương Đế', 'Vũ Tông Phan', 'Xa Lộ Hà Nội', 'Xuân Thủy'];
     $streets_quan2 = ['An Phú', 'An Phú Đông 27', 'An Trang', 'B', 'Bát Nàn', 'Bình An', 'Bình Trưng', 'Bùi Tá Hán', 'Cao Đức Lân', 'Đại Lộ Đông Tây', 'Đàm Văn Lễ', 'Đặng Hữu Phổ', 'Đặng Như Mai', 'Đặng Tiến Đông', 'Đỗ Pháp Thuận', 'Đỗ Quang', 'Đỗ Xuân Hợp', 'Đoàn Hữu Trưng', 'Đông Hưng Thuận 6', 'Đồng Quốc Bình', 'Đồng Văn Cống', 'Dư Hàng Kênh', 'Đường A', 'Đường C', 'Dương Văn An', 'G1', 'Giang Văn Minh', 'H', 'Hà Quang', 'Hàn Giang', 'Hậu Lân', 'Hiệp Thành 13', 'Hương lộ 62', 'K', 'KP3', 'Lâm Quang Ký', 'Lê Đình Quản', 'Lê Đức Thọ', 'Lê Hiến Mai', 'Lê Hồng Phong', 'Lê Hữu Kiều', 'Lê Phụng Hiểu', 'Lê Thước', 'Lê Văn Miến', 'Lê Văn Thịnh', 'Lộc Hòa', 'Lương Định Của', 'Lý Ông Trọng', 'Mai Chí Thọ', 'Mương Khai', 'Ngô Quang Huy', 'Nguyễn Án', 'Nguyễn Bá Huân', 'Nguyễn Bá Lân', 'Nguyễn Cừ', 'Nguyễn Đăng Đạo', 'Nguyễn Đăng Giai', 'Nguyễn Địa Lô', 'Nguyễn Đôn Tiết', 'Nguyễn Duy Hiệu', 'Nguyễn Duy Trinh', 'Nguyễn Hoàng', 'Nguyễn Hương', 'Nguyễn Huy Chương', 'Nguyễn Khanh', 'Nguyễn Khoa Đăng', 'Nguyễn Lương Dĩ', 'Nguyễn Quang Bật', 'Nguyễn Quý Cảnh', 'Nguyễn Quý Đức', 'Nguyễn Thanh Sơn', 'Nguyễn Thị Định', 'Nguyễn Trọng Quân', 'Nguyễn Trung Nguyệt', 'Nguyễn Tư Nghiêm', 'Nguyễn Tuyển', 'Nguyễn Ư Dĩ', 'Nguyễn Văn Giáp', 'Nguyễn Văn Hưởng', 'Nguyễn Văn Kỉnh', 'Phạm Công Trứ', 'Phạm Đôn Lễ', 'Phạm Hy Lượng', 'Phạm Thận Duật', 'Phan Bá Vành', 'Phan Văn Đáng', 'Quách Giai', 'Quốc Hương', 'Quốc lộ 1A', 'Song Hành', 'Sử Hy Nhan', 'Tạ Hiện', 'Tân Chánh Hiệp 16', 'Tân Lập 2', 'Tân Thới Hiệp 10', 'Thái Thuận', 'Thân Văn Nhiếp', 'Thạnh Lộc 27', 'Thạnh Mỹ Bắc', 'Thạnh Mỹ Lợi', 'Thạnh Mỹ Nam', 'Thạnh Xuân 13', 'Thạnh Xuân 21', 'Thảo Điền', 'Thích Mật Thể', 'Tỉnh Lộ 10', 'Tỉnh lộ 25B', 'Tống Hữu Định', 'Trại Gà', 'Trần Lưu', 'Trần Lựu', 'Trần Não', 'Trần Ngọc Diện', 'Trần Quang Đạo', 'Trích Sài', 'Trịnh Khắc Lập', 'Trúc Đường', 'Trương Gia Mô', 'Trương Văn Bang', 'Trương Văn Đa', 'Vạn Kiếp', 'Vành Đai 2', 'Vành Đai Đông', 'Võ Trường Toản', 'Võ Văn Kiệt', 'Vũ Phương Đế', 'Vũ Tông Phan', 'Xa Lộ Hà Nội', 'Xuân Thủy'];
     $quan2 = District::where('key', 'quan-2')->get();
     $quan2_id = 2;
     $quan2_name = 'Quận 2';
     if (is_null($quan2) || $quan2->count() == 0) {
         $quan2_id = $quan2_id[0]->id;
         $quan2_name = $quan2_id[0]->name;
     }
     foreach ($streets_quan2 as $key => $value) {
         $street = Street::create(['key' => Common::createKeyURL($value . ' ' . $quan2_name), 'name' => $value, 'district_id' => $quan2_id, 'meta_description' => 'Bán căn hộ đường phố ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ đường phố ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ đường phố ' . $value . ' ' . $quan2_name, 'meta_keywords' => 'Bán căn hộ đường phố ' . $value . ' ' . $quan2_name . ', sang nhượng căn hộ đường phố ' . $value . ' ' . $quan2_name . ', cho thuê căn hộ đường phố ' . $value . ' ' . $quan2_name, 'priority' => $key, 'is_publish' => 1, 'created_by' => 'vankhoe', 'updated_by' => 'vankhoe']);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $generator = \Faker\Factory::create('vi_VN');
     $value = 'Banner Chính 1';
     $navigation = Navigation::create(['key' => Common::createKeyURL($value), 'navigation_category_id' => 1, 'priority' => 0, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
     NavigationTranslation::create(['navigation_id' => $navigation->id, 'locale' => 'vi', 'name' => $value, 'summary' => $value]);
     Attachment::create(['entry_id' => $navigation->id, 'table_name' => 'navigations', 'path' => $generator->imageUrl($width = 1269, $height = 820), 'priority' => 0, 'is_publish' => 1]);
     // BANNER SOCIAL
     $navigationCategory = NavigationCategory::findByKey('banner-social')->first()->id;
     for ($i = 1; $i <= 3; $i++) {
         $navigation_name = $generator->sentence($nbWords = 6);
         $navigation = Navigation::create(['key' => Common::createKeyURL($navigation_name), 'navigation_category_id' => $navigationCategory, 'priority' => $i, 'is_publish' => 1, 'created_by' => 'phantsang', 'updated_by' => 'phantsang']);
         NavigationTranslation::create(['navigation_id' => $navigation->id, 'locale' => 'vi', 'name' => $navigation_name, 'summary' => $generator->text($maxNbChars = 50), 'content' => '']);
         Attachment::create(['entry_id' => $navigation->id, 'table_name' => 'navigations', 'path' => '/uploads/social' . $i . '.png', 'priority' => 0, 'is_publish' => 1]);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $controlname = $request->get('name');
     // getting all of the post data
     $file = array($controlname => $request->file($controlname));
     // setting up rules
     $rules = array('image' => 'mimes:jpg,jpeg,gif,png,pdf,rar,zip,7z,doc,docx,xls,xlsx,txt|max:5120');
     // doing the validation, passing post data, rules and the messages
     $validator = Validator::make($file, $rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return $results = ['error' => $validator->messages()->toArray()];
     } else {
         if ($request->hasFile($controlname)) {
             // checking file is valid.
             if ($request->file($controlname)->isValid()) {
                 $destinationPath = 'uploads';
                 // upload path
                 $filename = substr($request->file($controlname)->getClientOriginalName(), 0, strripos($request->file($controlname)->getClientOriginalName(), '.'));
                 $filename = Common::createKeyURL($filename);
                 $extension = $request->file($controlname)->getClientOriginalExtension();
                 // getting image extension
                 $date = new \DateTime();
                 $filename = $filename . '-' . $date->getTimestamp() . '.' . $extension;
                 // renameing image
                 $request->file($controlname)->move($destinationPath, $filename);
                 // uploading file to given path
                 if ($controlname != 'editorfile') {
                     //$filename = str_replace('.','-image(160x80-crop).', $filename);
                     $results = ['initialPreview' => ['<img src="/' . $destinationPath . '/' . $filename . '" class="file-preview-image">']];
                 } else {
                     $results = '/' . $destinationPath . '/' . $filename;
                 }
                 return $results;
             } else {
                 // sending back with error message.
                 return $results = ['error' => 'Lỗi trong quá trình upload.'];
             }
         } else {
             return $results = ['error' => 'Không nhận được dữ liệu.[' . $controlname . ']'];
         }
     }
 }
Exemple #29
0
 public static function payment(int $id, $user_id, string $company_id) : array
 {
     $company_shift_start = Company::where('id', $company_id)->select('shift_day_start as day', 'shift_night_start as night')->first();
     $roster = Roster::find($id)->users()->where('users.id', $user_id)->first();
     if (count($roster) > 0 && $roster->pivot->real_start_time != null && $roster->pivot->real_start_time != null) {
         $start_str = strtotime($roster->pivot->real_start_time);
         $end_str = strtotime($roster->pivot->real_end_time);
         $arr_times = [];
         $payment = 0;
         $time = 0;
         for ($i = $start_str; $i <= $end_str; $i += 300) {
             $current_checking_time = date("Y-m-d H:i:s", $i);
             $custom_payment_amount = Payment::custom($current_checking_time);
             if ($custom_payment_amount == 0) {
                 $id = date("N", $i) - 1;
                 if (Common::isTimeBetween(date("H:i:s", $i), $company_shift_start->day, $company_shift_start->night)) {
                     $id .= "_day";
                 } else {
                     $id .= "_night";
                 }
                 if ($roster->pivot->is_supervisor == 1) {
                     $id .= "_supervisor";
                 } else {
                     $id .= "_worker";
                 }
                 !isset($arr_times[$id]) ? $arr_times[$id] = 1 : ($arr_times[$id] += 1);
             } else {
                 $payment += $custom_payment_amount * (1 / 12);
                 $time += 1 / 12;
             }
         }
         foreach ($arr_times as $key => $time_count) {
             list($day, $period, $type) = explode('_', $key);
             $amount = Payment::week($day, $period, $type, $company_id);
             $payment += $amount * (5 / 60 * $time_count);
             $time += $time_count;
             //return var_dump($amount);
         }
         return ['payment' => number_format((double) $payment, 2, '.', '') ?? 0, 'time' => $time];
     }
     return ['payment' => 0, 'time' => 0];
 }
 /**
  * @param $url
  * @param null $user_id
  * @param null $token
  * @return json
  */
 public static function GET($url, $user_id = null, $token = null)
 {
     try {
         $ch = curl_init();
         if (FALSE === $ch) {
             throw new Exception('failed to initialize');
         }
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         if ($token != null) {
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', "Authorization: Bearer " . $token));
         }
         $content = curl_exec($ch);
         if (FALSE === $content) {
             throw new Exception(curl_error($ch), curl_errno($ch));
         }
     } catch (Exception $e) {
         trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);
     }
     $json = json_decode($content);
     if (isset($json->error)) {
         if ($json->error->code == 401) {
             $new_access_token = Tokens::refreshToken($user_id);
             $query = parse_url($url, PHP_URL_QUERY);
             parse_str($query, $val);
             $val['access_token'] = $new_access_token;
             $fixed_query = http_build_query($val);
             $_url = parse_url($url);
             $_url['query'] = $fixed_query;
             $new_url = file_get_contents(Common::http_build_url($url, $_url));
             $json = json_decode($new_url);
         } else {
             abort(500, $json->error->message);
         }
     }
     return $json;
 }