예제 #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function getCreate()
 {
     $languages = Language::all();
     $language = "";
     // Show the page
     return view('admin.objecttype.create_edit', compact('languages', 'language'));
 }
예제 #2
0
 public function edit($id)
 {
     if (Request::isMethod('get')) {
         $roles = UserRole::orderBy('id', 'desc')->get();
         $info = User::find($id);
         $cats = BlogCategory::where('lang_code', $info->userblog->lang_code)->get();
         $langs = Language::all();
         return view('admin.users.edit', array('cats' => $cats, 'langs' => $langs, 'info' => $info, 'roles' => $roles));
     }
     // POST
     parse_str(Request::input('data'));
     $category_save = implode(',', $category);
     $u = User::find($id);
     $u->name = $name;
     $u->address = $address;
     $u->zipcode = $zipcode;
     $u->city = $city;
     $u->phone = $phone;
     $u->cpr = $cpr;
     $u->role = $role;
     $u->account_number = $account_number;
     if ($password != null || $password != '') {
         $u->password = Hash::make($password);
     }
     $u->save();
     $info_update = array('blogname' => $blogname, 'domain' => $blogurl, 'lang_code' => $lang_code, 'blog_categories' => $category_save);
     UserBlog::where('user_id', $id)->update($info_update);
 }
예제 #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $photoalbum = PhotoAlbum::find($id);
     $language = $photoalbum->language_id;
     $languages = Language::all();
     return view('backend.photoalbum.create_edit', compact('photoalbum', 'languages', 'language'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $videoalbum = VideoAlbum::find($id);
     $language = $videoalbum->language_id;
     $languages = Language::all();
     return view('admin.videoalbum.create_edit', compact('videoalbum', 'languages', 'language'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $newscategory = ArticleCategory::find($id);
     $language = $newscategory->language_id;
     $languages = Language::all();
     return view('backend.newscategory.create_edit', compact('newscategory', 'languages', 'language'));
 }
 /**
  * JSON data for seeding Languages
  * @return \Illuminate\Http\JsonResponse
  * @throws \Exception
  */
 public function getLanguages()
 {
     return Datatable::collection(Language::all())->showColumns('title', 'code')->addColumn('updated_at', function ($model) {
         return $model->updated_at->diffForHumans();
     })->addColumn('', function ($model) {
         return get_ops('language', $model->id);
     })->searchColumns('title')->orderColumns('title', 'code')->make();
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $news = Article::find($id);
     $languages = Language::all();
     $language = $news->language_id;
     $newscategories = ArticleCategory::all();
     $newscategory = $news->newscategory_id;
     return view('admin.news.create_edit', compact('news', 'languages', 'language', 'newscategories', 'newscategory'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $statusCode = 200;
     $response = ['languages' => []];
     $languages = Language::all();
     foreach ($languages as $language) {
         $response['languages'][] = ['id' => $language->id, 'language' => $language->language];
     }
     return response($response, $statusCode);
 }
예제 #9
0
 public function search(Request $request)
 {
     // retrieve query from URL
     $q = $request->q;
     // SQL LIKE format for matching on search query:
     // %SEARCH_TERM%
     $q_query = '%' . $q . '%';
     $questions = Question::where('title', 'LIKE', $q_query)->orWhere('description', 'LIKE', $q_query)->orWhere('code', 'LIKE', $q_query)->get();
     return view('questions.search', ['q' => $q, 'questions' => $questions, 'languages' => Language::all()]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $city = City::findOrFail($id);
     $country = Country::all();
     $language = Language::all();
     $languages_cur = $city->language;
     foreach ($languages_cur as $language_cur) {
         $lang[] = $language_cur['id'];
     }
     return view('editCity', ['id' => $id, 'city' => $city->city, 'country_cur' => $city->country_id, 'languages_cur' => $lang, 'countries' => $country, 'languages' => $language]);
 }
 public function showUserProfile()
 {
     $user = User::getUserProfile();
     $languages = Language::all();
     if ($user['status'] != '200') {
         return Render::errorPage($user['status']);
     }
     //if error
     $countries = Country::getAll();
     return view('backend.user.profile')->with('content_title', 'My Profile')->with('languages', $languages)->with('countries', $countries)->with('user_info', $user['data']['user_info'])->with('user_role', $user['data']['user_role']);
 }
예제 #12
0
 public function edit($id)
 {
     if (Request::isMethod('get')) {
         $lang = Language::all();
         $info = BlogCategory::find($id);
         return view('admin.blogcategories.edit', array('lang' => $lang, 'info' => $info));
     }
     $data = Request::all();
     $c = BlogCategory::find($id);
     $c->name = $data['name'];
     $c->lang_code = $data['lang_code'];
     $c->save();
     return redirect('admin/blog-categories')->with('ok', 'Saved');
 }
예제 #13
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($company_id)
 {
     $company = Company::find($company_id);
     $countries = Country::all();
     foreach ($countries as $ctr) {
         $country_names[$ctr->id] = $ctr->name;
     }
     $cities = City::all();
     foreach ($cities as $ct) {
         $city_names[$ct->id] = $ct->name;
     }
     foreach (Language::all() as $lang) {
         $langs[$lang->id] = $lang->name;
     }
     return view('jobs.create', compact('country_names', 'city_names', 'langs', 'company'));
 }
예제 #14
0
 public function index()
 {
     if (Request::isMethod('get')) {
         $lang = Language::all();
         $settings = Setting::all();
         return view('admin.settings.index', array('langs' => $lang, 'settings' => $settings));
     }
     /// POST
     $data = Request::all();
     $s = new Setting();
     $s->name = $data['name'];
     $s->lang_code = $data['lang_code'];
     $s->value = $data['value'];
     $s->type = 'var';
     $s->save();
     return redirect('admin/settings');
 }
예제 #15
0
 /**
  * Display list language
  * @return Response
  */
 public function index()
 {
     $languages = Language::all();
     $filesobj = File::files(base_path() . '/resources/lang/en/');
     $files = array();
     $count_nhat = 0;
     $count_english = 0;
     foreach ($filesobj as $key => $value) {
         $namefile = basename($value);
         $tienganh = File::getRequire(base_path() . '/resources/lang/en/' . $namefile);
         $tiengnhat = File::getRequire(base_path() . '/resources/lang/jp/' . $namefile);
         foreach ($tienganh as $key => $value) {
             $count_english++;
             if (array_key_exists($key, $tiengnhat)) {
                 if ($tiengnhat[$key] != '') {
                     $count_nhat++;
                 }
             }
         }
     }
     $percent_language = round($count_nhat / $count_english * 100, 0);
     return view('language', compact('languages', 'percent_language'));
 }
예제 #16
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $language = Language::findOrFail($id);
     return view('languages.show', ['language' => $language, 'languages' => Language::all()]);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('positions')) {
         $positions = Position::all();
         $selectPositions = array();
         $selectPositions[0] = "Select / All";
         foreach ($positions as $position) {
             $selectPositions[$position->slug] = $position->name;
         }
         \View::share('selectPositions', $selectPositions);
     }
     if (\Schema::hasTable('cases_priorities')) {
         $priorities = CasePriority::all();
         $selectPriorities = array();
         $selectPriorities[0] = "Select / All";
         foreach ($priorities as $priority) {
             $selectPriorities[$priority->slug] = $priority->name;
         }
         \View::share('selectPriorities', $selectPriorities);
     }
     if (\Schema::hasTable('titles')) {
         $titles = Title::all();
         $selectTitles = array();
         $selectTitles[0] = "Select / All";
         foreach ($titles as $title) {
             $selectTitles[$title->slug] = $title->name;
         }
         \View::share('selectTitles', $selectTitles);
     }
     if (\Schema::hasTable('languages')) {
         $languages = Language::all();
         $selectLanguages = array();
         $selectLanguages[0] = "Select / All";
         foreach ($languages as $language) {
             $selectLanguages[$language->slug] = $language->name;
         }
         \View::share('selectLanguages', $selectLanguages);
     }
     if (\Schema::hasTable('departments')) {
         $departments = Department::all();
         $selectDepartments = array();
         $selectDepartments[0] = "Select / All";
         foreach ($departments as $department) {
             $selectDepartments[$department->slug] = $department->name;
         }
         \View::share('selectDepartments', $selectDepartments);
     }
     if (\Schema::hasTable('users_roles')) {
         $roles = UserRole::all();
         $selectRoles = array();
         $selectRoles[0] = "Select / All";
         foreach ($roles as $role) {
             $selectRoles[$role->slug] = $role->name;
         }
         \View::share('selectRoles', $selectRoles);
     }
     if (\Schema::hasTable('provinces')) {
         $provinces = Province::all();
         $selectProvinces = array();
         $selectProvinces[0] = "Select / All";
         foreach ($provinces as $Province) {
             $selectProvinces[$Province->slug] = $Province->name;
         }
         \View::share('selectProvinces', $selectProvinces);
     }
     if (\Schema::hasTable('districts')) {
         $districts = District::all();
         $selectDistrict = array();
         $selectDistricts[0] = "Select / All";
         foreach ($districts as $district) {
             $selectDistricts[$district->slug] = $district->name;
         }
         \View::share('selectDistricts', $selectDistricts);
     }
     if (\Schema::hasTable('municipalities')) {
         $municipalities = Municipality::all();
         $selectMunicipalities = array();
         $selectMunicipalities[0] = "Select / All";
         foreach ($municipalities as $municipality) {
             $selectMunicipalities[$municipality->slug] = $municipality->name;
         }
         \View::share('selectMunicipalities', $selectMunicipalities);
     }
     if (\Schema::hasTable('wards')) {
         $wards = Ward::all();
         $selectWards = array();
         $selectWards[0] = "Select / All";
         foreach ($wards as $ward) {
             $selectWards[$ward->slug] = $ward->name;
         }
         \View::share('selectWards', $selectWards);
     }
     if (\Schema::hasTable('categories')) {
         $categories = Category::all();
         $selectCategories = array();
         $selectCategories[0] = "Select / All";
         foreach ($categories as $category) {
             $selectCategories[$category->slug] = $category->name;
         }
         \View::share('selectCategories', $selectCategories);
     }
     if (\Schema::hasTable('sub_categories')) {
         $subCategories = SubCategory::all();
         $selectSubCategories = array();
         $selectSubCategories[0] = "Select / All";
         foreach ($subCategories as $subCategory) {
             $selectSubCategories[$subCategory->slug] = $subCategory->name;
         }
         \View::share('selectSubCategories', $selectSubCategories);
     }
     if (\Schema::hasTable('sub_sub_categories')) {
         $subSubCategories = SubSubCategory::all();
         $selectSubSubCategories = array();
         $selectSubSubCategories[0] = "Select / All";
         foreach ($subSubCategories as $subSubCategory) {
             $selectSubSubCategories[$subSubCategory->slug] = $subSubCategory->name;
         }
         \View::share('selectSubSubCategories', $selectSubSubCategories);
     }
     if (\Schema::hasTable('relationships')) {
         $relationships = Relationship::all();
         $selectRelationships = array();
         $selectRelationships[0] = "Select / All";
         foreach ($relationships as $relationship) {
             $selectRelationships[$relationship->id] = $relationship->name;
         }
         \View::share('selectRelationships', $selectRelationships);
     }
     if (\Schema::hasTable('cases')) {
         $cases = \DB::table('cases')->join('users', 'cases.reporter', '=', 'users.id')->select(\DB::raw("\n                                                    IF(`cases`.`addressbook` = 1,(SELECT CONCAT(`first_name`, ' ', `surname`) FROM `addressbook` WHERE `addressbook`.`id`= `cases`.`reporter`), (SELECT CONCAT(users.`name`, ' ', users.`surname`) FROM `users` WHERE `users`.`id`= `cases`.`reporter`)) as reporterName\n\n                                                "))->get();
         $reporters = array();
         $reporters[0] = "Select / All";
         foreach ($cases as $case) {
             $reporters[$case->reporterName] = $case->reporterName;
         }
         \View::share('selectReporters', $reporters);
     }
     View()->composer('master', function ($view) {
         $view->with('addressBookNumber', addressbook::all());
         if (\Auth::check()) {
             $number = addressbook::where('user', '=', \Auth::user()->id)->get();
             $view->with('addressBookNumber', $number);
             $allUsers = User::where('id', '<>', \Auth::user()->id)->get();
             $view->with('loggedInUsers', $allUsers);
             $noPrivateMessages = Message::where('to', '=', \Auth::user()->id)->where('read', '=', 0)->where('message_type', '=', 0)->get();
             $view->with('noPrivateMessages', $noPrivateMessages);
             $noInboxMessages = Message::where('to', '=', \Auth::user()->id)->where('message_type', '=', 0)->get();
             $view->with('noInboxMessages', $noInboxMessages);
             $noDepartments = Department::all();
             $view->with('noDepartments', $noDepartments);
             $noUsers = User::all();
             $view->with('noUsers', $noUsers);
             $noRoles = UserRole::all();
             $view->with('noRoles', $noRoles);
             $noPositions = Position::all();
             $view->with('noPositions', $noPositions);
             $noRelationships = Relationship::all();
             $view->with('noRelationships', $noRelationships);
             $noProvinces = Province::all();
             $view->with('noProvinces', $noProvinces);
             $noCaseStatuses = CaseStatus::all();
             $view->with('noCaseStatuses', $noCaseStatuses);
             $userRole = UserRole::where('id', '=', \Auth::user()->role)->first();
             $view->with('systemRole', $userRole);
             $noCasesPriorities = CasePriority::all();
             $view->with('noCasesPriorities', $noCasesPriorities);
         }
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $languages = Language::all();
     return response()->json($languages);
 }
예제 #19
0
 /**
  * Store all languages in a config variable
  */
 public function __construct()
 {
     Config::set(['languages' => Language::all()]);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $photo = Photo::find($id);
     $languages = Language::all();
     $language = $photo->language_id;
     $photoalbums = PhotoAlbum::all();
     $photoalbum = $photo->photo_album_id;
     return view('admin.photo.create_edit', compact('photo', 'languages', 'language', 'photoalbums', 'photoalbum'));
 }
예제 #21
0
 public function index()
 {
     $exportExcel = Request::input('exportExcel');
     $lang = Request::input('lang');
     $status = Request::input('status');
     $period = Request::input('period');
     $period_to = Request::input('period_to');
     $data = array();
     $data['langs'] = Language::all();
     $users = User::where('role', '<>', 1)->get(array('id', 'name', 'cpr', 'account_number'));
     $list_user_assigns = array();
     $list_users_lang = array();
     /// filter by langs
     if ($lang && $lang == 'all' || !$lang) {
         foreach ($users as $k => $u) {
             $num = UserBlog::where('user_id', $u->id)->first();
             if ($num) {
                 $list_users_lang[$k] = $u;
                 $list_users_lang[$k]['star'] = $num->star;
                 $list_users_lang[$k]['lang_code'] = $num->lang_code;
                 $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value;
                 if (!$star_value) {
                     $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value;
                 }
                 $list_users_lang[$k]['star_value'] = $star_value;
                 $list_users_lang[$k]['total_amount'] = 0;
             }
         }
     } elseif ($lang && $lang != 'all') {
         foreach ($users as $k => $u) {
             $num = UserBlog::where('user_id', $u->id)->where('lang_code', $lang)->first();
             if ($num) {
                 $list_users_lang[$k] = $u;
                 $list_users_lang[$k]['star'] = $num->star;
                 $list_users_lang[$k]['lang_code'] = $num->lang_code;
                 $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value;
                 if (!$star_value) {
                     $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value;
                 }
                 $list_users_lang[$k]['star_value'] = $star_value;
                 $list_users_lang[$k]['total_amount'] = 0;
             }
         }
     }
     /// filter by status
     /// if status == all or dont isset status
     if ($status && $status == 'all' || !$status) {
         foreach ($list_users_lang as $k_u_l => $v_u_l) {
             /// if period = null, dont query by date
             if ($period == '' || !$period) {
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             } else {
                 // if isset period and period != null
                 $period = date('Y-m-d 00:00:00', strtotime($period));
                 $period_to = date('Y-m-d 23:59:59', strtotime($period_to));
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             }
             if (count($ua)) {
                 $list_user_assigns[$k_u_l] = $v_u_l;
                 $list_user_assigns[$k_u_l]['user_assignment'] = $ua;
                 foreach ($ua as $key_ua => $value_ua) {
                     $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value'];
                     $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'];
                 }
             }
         }
     } elseif ($status && $status != 'all') {
         foreach ($list_users_lang as $k_u_l => $v_u_l) {
             if ($period == '' || !$period) {
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             } else {
                 $period = date('Y-m-d 00:00:00', strtotime($period));
                 $period_to = date('Y-m-d 23:59:59', strtotime($period_to));
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             }
             if (count($ua)) {
                 $list_user_assigns[$k_u_l] = $v_u_l;
                 $list_user_assigns[$k_u_l]['user_assignment'] = $ua;
                 foreach ($ua as $key_ua => $value_ua) {
                     $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value'];
                     $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'];
                 }
             }
         }
     }
     /// export excel
     if ($exportExcel) {
         return $this->exportExcel($list_user_assigns);
     }
     return view('admin.payment-list.index', array('users' => $list_user_assigns, 'langs' => $data['langs']));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // validate request
     $validateProvince = Validator::make($request->get('Province'), Province::$rules);
     $validationMessages = [];
     foreach ($request->get('ProvinceTranslation') as $key => $value) {
         $validateProvinceTranslation = Validator::make($value, ProvinceTranslation::$rules);
         if ($validateProvinceTranslation->fails()) {
             $validationMessages = array_merge_recursive($validationMessages, $validateProvinceTranslation->messages()->toArray());
         }
     }
     if ($validateProvince->fails() or count($validationMessages) > 0) {
         $validationMessages = array_merge_recursive($validateProvince->messages()->toArray(), $validationMessages);
         return redirect()->back()->withErrors($validationMessages)->withInput();
     }
     // get all languages
     $languages = Language::all();
     // find language default
     $languageDefault = $languages->where('is_key_language', 1)->first();
     if (is_null($languageDefault)) {
         $languageDefault = $languages->first();
     }
     // sure execute success, if not success rollback
     DB::transaction(function () use($request, $id, $languageDefault) {
         $user = $request->user();
         // insert Province
         $province = Province::findOrFail($id);
         $province->key = Common::createKeyURL($request->input('ProvinceTranslation.' . $languageDefault->code . '.name'));
         $province->priority = $request->input('Province.priority');
         $province->is_publish = $request->input('Province.is_publish');
         $province->created_by = $user->name;
         $province->updated_by = $user->name;
         $province->save();
         // save data languages
         foreach ($request->get('ProvinceTranslation') as $locale => $value) {
             $province->translateOrNew($locale)->name = $request->input('ProvinceTranslation.' . $locale . '.name');
         }
         $province->save();
     });
     return redirect()->route('admin.provinces.index');
 }
예제 #23
0
 public function index()
 {
     return Language::all();
 }
예제 #24
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Get all languages from database
     $languages = Language::all();
     return view('languages.index')->with('title', 'Languages')->with('heading', 'Languages')->with('languages', $languages);
 }
예제 #25
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getEdit($id)
 {
     $video = Video::find($id);
     if ($video->youtube != "") {
         $video->youtube = 'https://www.youtube.com/watch?v=' . $video->youtube;
     }
     $languages = Language::all();
     $language = $video->language_id;
     $videoalbums = VideoAlbum::all();
     $videoalbum = $video->video_album_id;
     return view('backend.video.create_edit', compact('video', 'languages', 'language', 'videoalbums', 'videoalbum'));
 }
예제 #26
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return view('admin.languages.index', ['languages' => Language::all()]);
 }
예제 #27
0
 public function languages()
 {
     $languages = Language::all();
     return view('langs.all', compact('languages'));
 }
예제 #28
0
 public function quick_create_assignment()
 {
     if (Request::isMethod('get')) {
         if (Request::input('key') && Request::input('key') == '8855a5gp2C6577') {
             $customerAPI = json_decode($this->curlGet());
             $langs = Language::all();
             return view('admin.assignment.quick-create', array('langs' => $langs, 'customerAPI' => $customerAPI));
         } else {
             return 'You do not have permission to view this page';
         }
     }
     /*
     	POST link is link id in riversystem DB, bf_links
     */
     $data = Request::all();
     $customer = $data['customer'];
     $release_date = $data['release_date'];
     $customerName = $data['customerName'];
     $max_blogger = $data['max_blogger'];
     $lang_code = $data['lang_code'];
     $keyword = $data['keyword'];
     $minimum_wordcount = $data['minimum_wordcount'];
     if (isset($data['img'])) {
         $img = $data['img'];
     } else {
         $img = null;
     }
     $categories = implode(',', $data['category']);
     if (isset($data['link'])) {
         $link = $data['link'];
     } else {
         $link = null;
     }
     if (isset($data['anchor_text'])) {
         $anchor_text = $data['anchor_text'];
     }
     if ($link) {
         foreach ($link as $key => $value) {
             $listUploadedImg_Link[$key]['img'] = $img[$key];
             $listUploadedImg_Link[$key]['link'] = $link[$key];
             $listUploadedImg_Link[$key]['anchor_text'] = $anchor_text[$key];
         }
         $imgLink_store = json_encode($listUploadedImg_Link);
     } else {
         $imgLink_store = null;
     }
     foreach ($release_date as $key => $release_date_val) {
         $a = new Assignment();
         $a->customer_id = $customer;
         $a->customer_name = $customerName;
         $a->keyword = $keyword;
         $a->minimum_wordcount = $minimum_wordcount;
         $a->max_blogger = $max_blogger;
         $a->blog_categories = $categories;
         $a->lang_code = $lang_code;
         $a->img_link = $imgLink_store;
         $a->release_date = $release_date_val;
         $a->save();
     }
     return redirect('admin/quick-create-assignment?key=8855a5gp2C6577')->with('ok', 'Create Assignment Successful');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // validate request
     $validateProductColor = Validator::make($request->get('ProductColor'), ProductColor::$rules);
     $validationMessages = [];
     foreach ($request->get('ProductColorTranslation') as $key => $value) {
         $validateProductColorTranslation = Validator::make($value, ProductColorTranslation::$rules);
         if ($validateProductColorTranslation->fails()) {
             $validationMessages = array_merge_recursive($validationMessages, $validateProductColorTranslation->messages()->toArray());
         }
     }
     if ($validateProductColor->fails() or count($validationMessages) > 0) {
         $validationMessages = array_merge_recursive($validateProductColor->messages()->toArray(), $validationMessages);
         return redirect()->back()->withErrors($validationMessages)->withInput();
     }
     // get all languages
     $languages = Language::all();
     // find language default
     $languageDefault = $languages->where('is_key_language', 1)->first();
     if (is_null($languageDefault)) {
         $languageDefault = $languages->first();
     }
     // sure execute success, if not success rollback
     DB::transaction(function () use($request, $id, $languageDefault) {
         $user = $request->user();
         // insert ProductColor
         $productColor = ProductColor::findOrFail($id);
         $productColor->key = Common::createKeyURL($request->input('ProductColorTranslation.' . $languageDefault->code . '.name'));
         $productColor->parent_id = $request->input('ProductColor.parent_id');
         $productColor->priority = $request->input('ProductColor.priority');
         $productColor->is_publish = $request->input('ProductColor.is_publish');
         $productColor->created_by = $user->name;
         $productColor->updated_by = $user->name;
         $productColor->save();
         // save attachments
         // only insert or delete, not update
         if ($request->input('ProductColor.attachments') != "") {
             $currentAttachments = $productColor->attachments->lists('id');
             $requestAttachments = explode(',', $request->input('ProductColor.attachments'));
             $attachments = [];
             $keepAttachments = [];
             foreach ($requestAttachments as $key => $value) {
                 if (strpos($value, '|') === false) {
                     array_push($attachments, new Attachment(['entry_id' => $productColor->id, 'table_name' => 'product_colors', 'path' => $value, 'priority' => 0, 'is_publish' => 1]));
                 } else {
                     $attachmentId = explode('|', $value)[0];
                     array_push($keepAttachments, $attachmentId);
                 }
             }
             if (count($attachments) > 0) {
                 $productColor->attachments()->saveMany($attachments);
             }
             // delete attachments
             foreach ($currentAttachments as $key => $value) {
                 if (!in_array($value, $keepAttachments)) {
                     Attachment::findOrFail($value)->delete();
                 }
             }
         }
         // save data languages
         foreach ($request->get('ProductColorTranslation') as $locale => $value) {
             $productColor->translateOrNew($locale)->name = $request->input('ProductColorTranslation.' . $locale . '.name');
             $productColor->translateOrNew($locale)->summary = $request->input('ProductColorTranslation.' . $locale . '.summary');
             $productColor->translateOrNew($locale)->meta_description = $request->input('ProductColorTranslation.' . $locale . '.meta_description');
             $productColor->translateOrNew($locale)->meta_keywords = $request->input('ProductColorTranslation.' . $locale . '.meta_keywords');
         }
         $productColor->save();
     });
     return redirect()->route('admin.productcolors.index');
 }
 public function search()
 {
     //helpers
     $rating_date = mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()));
     //get form select options and quality radio buttons
     $brands = Brand::companyBrands()->get()->lists('name', 'id');
     $residences = Residence::companyResidences()->get()->lists('name', 'id');
     $companies = Company::userCompanies()->get()->lists('name', 'id');
     $companies_ids = Company::userCompanies()->get()->lists('id');
     foreach ($companies_ids as $company_id) {
         $company_ids[] = $company_id;
     }
     $languages = Language::all()->lists('name', 'id');
     array_unshift($languages, "Choose other language");
     $qualities = Qualities::CompanyQualities()->get();
     $inputs = Input::all();
     $employees = Employee::query();
     $employees->whereIn('company_id', $company_ids)->with('company', 'residence', 'phone', 'qualities', 'language')->with(['dates' => function ($query) {
         $query->whereRaw('(? BETWEEN dates.start AND dates.end OR dates.start>?) AND dates.type IN("day_off", "annual_leave")', array(mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time())), mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()))));
     }]);
     //dd($inputs);
     if (Input::has('company_id') && is_array($inputs['company_id'])) {
         $employees->whereIn('company_id', $inputs['company_id']);
     }
     if (Input::has('nickname')) {
         $employees->where('nickname', 'like', '%' . $inputs['nickname'] . '%');
     }
     if (Input::has('name')) {
         $employees->where('name', 'like', '%' . $inputs['name'] . '%');
     }
     if (Input::has('brand_id') && is_array($inputs['brand_id'])) {
         $employees->join('brand_employee', 'employees.id', '=', 'brand_employee.employee_id')->whereIn('brand_employee.brand_id', $inputs['brand_id']);
     }
     if (Input::has('residences_id') && is_array($inputs['residences_id'])) {
         $employees->whereIn('residences_id', $inputs['residences_id']);
     }
     if (Input::has('address')) {
         $employees->where('address', 'like', '%' . $inputs['address'] . '%');
     }
     if (Input::has('phone')) {
         $employees->join('phones', 'employees.id', '=', 'phones.employee_id')->where('phones.number', 'like', '%' . $inputs['phone'] . '%');
     }
     if (Input::has('email')) {
         $employees->where('email', 'like', '%' . $inputs['email'] . '%');
     }
     if (Input::has('agreement')) {
         $employees->where('agreement', 'like', '%' . $inputs['agreement'] . '%');
     }
     if (Input::has('no_agreement') && $inputs['agreement'] == '') {
         $employees->where('agreement', '=', '');
     }
     if (Input::has('signed_agreement')) {
         $employees->where('signed_agreement', '=', $inputs['signed_agreement']);
     }
     if (Input::has('working_days')) {
         $all_work = array_fill(0, 7, 0);
         foreach ($inputs['working_days'] as $work_day) {
             $all_work[$work_day] = 1;
         }
         $employees->where('working_days', 'like', implode('', $all_work));
     }
     if (Input::has('start_from')) {
         $employees->where('start_from', '<=', $inputs['start_from']);
     }
     if (Input::has('early_finish')) {
         $employees->where('early_finish', '>=', $inputs['early_finish']);
     }
     if (Input::has('birth_date') && $inputs['birth_date']['from'] != '') {
         $birth_date_start = strtotime($inputs['birth_date']['from']);
         $birth_date_end = strtotime($inputs['birth_date']['to']);
         if ($inputs['birth_date']['to'] == '') {
             $birth_date_end = strtotime($inputs['birth_date']['from']) + 60 * 60 * 24;
         }
         $employees->whereBetween('birth_date', [$birth_date_start, $birth_date_end]);
     }
     if (Input::has('start_date') && $inputs['start_date']['start'] != '') {
         $start_date_start = strtotime($inputs['start_date']['start']);
         $start_date_end = strtotime($inputs['start_date']['end']);
         if ($inputs['start_date']['end'] == '') {
             $start_date_end = $rating_date;
         }
         $employees->whereBetween('start_date', [$start_date_start, $start_date_end]);
     }
     if (Input::has('annual_leave') && $inputs['annual_leave']['start'] != '') {
         $leave_start = strtotime($inputs['annual_leave']['start']);
         $leave_end = strtotime($inputs['annual_leave']['end']);
         if ($inputs['annual_leave']['end'] == '') {
             $leave_end = $leave_start + 60 * 60 * 24;
         }
         $employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'annual_leave')->whereBetween('dates.start', [$leave_start, $leave_end])->orWhere(function ($query) use($leave_start, $leave_end) {
             $query->whereBetween('dates.end', [$leave_start, $leave_end]);
         });
     }
     if (Input::has('day_off') && $inputs['day_off']['start'] != '') {
         $dayoff_start = strtotime($inputs['day_off']['start']);
         $dayoff_end = strtotime($inputs['day_off']['end']);
         if ($inputs['day_off']['end'] == '') {
             $dayoff_end = $dayoff_start + 60 * 60 * 24;
         }
         $employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'day_off')->whereBetween('dates.start', [$dayoff_start, $dayoff_end])->orWhere(function ($query) use($dayoff_start, $dayoff_end) {
             $query->whereBetween('dates.end', [$dayoff_start, $dayoff_end]);
         });
     }
     if (Input::has('quit_date') && $inputs['quit_date']['start'] != '') {
         $quit_start = strtotime($inputs['quit_date']['start']);
         $quit_end = strtotime($inputs['quit_date']['end']);
         if ($inputs['quit_date']['end'] == '') {
             $quit_end = $quit_start + 60 * 60 * 24;
         }
         $employees->join('dates', 'employees.id', '=', 'dates.employees_id')->whereBetween('dates.end', [$quit_start, $quit_end]);
     }
     if (Input::has('en_language')) {
         $levels = array('excellent', 'very_good', 'good', 'average', 'bad', 'basic');
         foreach ($inputs['en_language'] as $level) {
             $search_levels[] = $levels[$level];
         }
         $employees->join('employee_language', 'employees.id', '=', 'employee_language.employee_id')->where('language_id', '=', 'en')->whereIn('level', $search_levels);
     }
     if (Input::has('languages') && sizeof($inputs['languages']) > 1) {
         $employees->join('employee_language', 'employees.id', '=', 'employee_language.employee_id')->whereIn('language_id', $inputs['languages']);
     }
     if (Input::has('uniform_size') && $inputs['uniform_size'] != '') {
         $employees->where('uniform_size', 'like', $inputs['uniform_size']);
     }
     if (Input::has('rate') && $inputs['rate'] != '') {
         $employees->where('rate', 'like', $inputs['rate']);
     }
     if (Input::has('quality')) {
         $employees->join('employee_quality', 'employees.id', '=', 'employee_quality.employee_id');
         foreach ($inputs['quality'] as $quality_id => $quality_value) {
             if ($quality_value == 0) {
                 $employees->whereRaw('employees.id NOT IN(SELECT employee_id FROM employee_quality WHERE qualities_id=?)', [$quality_id]);
             } else {
                 $employees->where('employee_quality.qualities_id', '=', $quality_id);
             }
         }
     }
     if (Input::has('smoker')) {
         $employees->where('smoker', '=', $inputs['smoker']);
     }
     if (Input::has('debt')) {
         $employees->where('debt', '=', $inputs['debt']);
     }
     if (Input::has('grade')) {
         foreach ($inputs['grade'] as $grade_level) {
             $employees->orWhere('average_grade', '>=', $grade_level)->where('average_grade', '<', $grade_level + 1);
         }
     }
     if (Input::has('rating')) {
         foreach ($inputs['rating'] as $rating) {
             $rating_array[] = $rating;
         }
         $employees->whereIn('rating', $rating_array);
     }
     if (Input::has('status')) {
         $count = 0;
         foreach ($inputs['status'] as $name => $status) {
             if ($count == 0) {
                 $employees->where('status', $name);
             } else {
                 $employees->orWhere('status', $name);
             }
             $count++;
         }
     }
     // var_dump($employees->get()->toArray());
     $employees = $employees->get();
     return view('search', compact('brands', 'residences', 'languages', 'employees', 'rating_date', 'qualities', 'companies'));
 }