コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $domain = \Issue\Domain::create(['parent_id' => 0]);
     $domainNames = ['ro' => 'Domenii', 'en' => 'Domains'];
     foreach (['ro', 'en'] as $locale) {
         $domain->translateOrNew($locale)->name = $domainNames[$locale];
     }
     $domain->save();
 }
コード例 #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('frontend.layout.header', function ($view) {
         $view->with('user', Auth::user());
     });
     view()->composer('frontend.partials.domainsTree', function ($view) {
         $domains = Domain::getCurrentDomains();
         $tree = Domain::getTree(Domain::getDomainsForTree($domains));
         $view->with(['tree' => $tree, 'domains' => $tree[1]['subdomains']]);
     });
     view()->composer('frontend.partials.domainsTreeForReports', function ($view) {
         $domains = Domain::getCurrentDomains();
         $tree = Domain::getTree(Domain::getDomainsForTree($domains));
         $view->with(['tree' => $tree, 'domains' => $tree[1]['subdomains']]);
     });
     Document::deleted(function ($document) {
         $fileToDelete = UploadedFile::where('id', '=', $document['uploaded_file_id'])->get();
         $fileToDelete = $fileToDelete[0]['file_name'];
         File::delete(storage_path() . '/documents/' . $fileToDelete);
         $document->file()->delete();
         return true;
     });
 }
コード例 #3
0
 public function queryDomain(Request $request)
 {
     $queryDomainName = $request->input('name');
     $domainIds = DomainTranslation::where('name', 'like', '%' . $queryDomainName . '%')->where('locale', \App::getLocale())->lists('domain_id');
     $domains = Domain::whereIn('id', $domainIds)->where('parent_id', '>', 0)->with(['translations', 'parent'])->get();
     $result = [];
     foreach ($domains as $domain) {
         $result[] = ['id' => $domain->id, 'name' => ($domain->parent->id > 1 ? $domain->parent->name . " - " : "") . $domain->name];
     }
     return $result;
 }
コード例 #4
0
 public function getReports(Request $request)
 {
     $domainsForReports = Domain::getCurrentDomains();
     if ($request->domain) {
         $domain = $domainsForReports->find($request->domain);
         if ($domain) {
             $domainsForReports = collect([$domain]);
         }
     }
     $reports = Report::bySearchTerm($request->report_search)->byDomainIds($domainsForReports->lists('id')->toArray())->orderBy('id', 'desc')->where(function ($query) use($request) {
         if ($request->report_type) {
             $query = $query->orWhere('report_type', $request->report_type);
         }
     })->paginate(5);
     return view('frontend.pages.reports', ['reports' => $reports, 'report_type' => $request->report_type, 'report_search' => $request->report_search, 'domain' => $request->domain]);
 }
コード例 #5
0
 protected function importDomains()
 {
     $domain = Domain::create(['parent_id' => 0]);
     $domainNames = ['ro' => 'Domenii', 'en' => 'Domains'];
     foreach (['ro', 'en'] as $locale) {
         $domain->translateOrNew($locale)->name = $domainNames[$locale];
     }
     $domain->save();
     $lvl1domains = DB::connection('oldissue')->select('select * from syslexdomain');
     $lvl2domains = DB::connection('oldissue')->select('select * from syslexarea');
     foreach ($lvl1domains as $domain) {
         $newDomain = new Domain();
         $newDomain->id = $domain->lexdomainID;
         $newDomain->parent_id = 1;
         $translatableData = ['ro' => ['name' => $domain->name ? $domain->name : ''], 'en' => ['name' => $domain->enname ? $domain->enname : '']];
         $newDomain->fill($translatableData);
         $newDomain->save();
     }
     foreach ($lvl2domains as $domain) {
         $newDomain = new Domain();
         $newDomain->id = $domain->lexareaID;
         $newDomain->parent_id = $domain->domainID;
         $translatableData = ['ro' => ['name' => $domain->name ? $domain->name : ''], 'en' => ['name' => $domain->enname ? $domain->enname : '']];
         $newDomain->fill($translatableData);
         $newDomain->save();
     }
     return print_r('Au fost importate: ' . Domain::count() . ' domenii.' . "\n");
 }