public function index()
 {
     $projects = Project::latest()->where('published', 1)->get();
     $illustrations = Illustration::latest()->get();
     $logos = Logo::latest()->get();
     return view('front', compact('projects', 'illustrations', 'logos'));
 }
 public function showDashboard()
 {
     $projects = new Project();
     $projectCount = $projects->count();
     $published = $projects->where('published', 1)->count();
     $unpublished = $projects->where('published', 0)->count();
     $illustrations = Illustration::count();
     $logos = Logo::count();
     return view('dashboard/dashboard', compact('projectCount', 'published', 'unpublished', 'illustrations', 'logos'));
 }
 public function removeLogo(Request $request)
 {
     if ($request->imageName) {
         $logo = Logo::where('thumb', $request->imageName)->firstOrFail();
         $logoPath = 'build/images/logos/';
         $logoName = $logo->image;
         $logoThumb = $logo->thumb;
         Storage::disk('public')->delete($logoPath . $logoName);
         Storage::disk('public')->delete($logoPath . $logoThumb);
         $logo->delete();
         return 'ok';
     } else {
         return 'failed';
     }
 }
 public static function getConfigWithUrl($chart)
 {
     $config = json_decode($chart->config);
     $config->id = $chart->id;
     $config->{"chart-notes"} = $chart->notes;
     $config->{"chart-slug"} = $chart->slug;
     $config->{"data-entry-url"} = $chart->origin_url;
     // Allow url parameters to override the chart's default
     // selected countries configuration. We need to use the raw
     // query string for this because we want to distinguish between
     // %20 and +.
     preg_match("/country=([^&]+)/", $_SERVER['QUERY_STRING'], $matches);
     if ($matches) {
         $countryCodes = array_map(function ($code) {
             return urldecode($code);
         }, explode("+", $matches[1]));
         $query = DB::table('entities')->select('id', 'name')->whereIn('code', $countryCodes)->orWhere(function ($query) use($countryCodes) {
             $query->whereIn('name', $countryCodes);
         });
         $config->{"selected-countries"} = $query->get();
     }
     // Remove any invalid variables from the chart config
     $dims = json_decode($config->{"chart-dimensions"});
     $varIds = array_map(function ($d) {
         return $d->variableId;
     }, $dims);
     $existingIds = DB::table("variables")->select('id')->whereIn('id', $varIds)->lists('name', 'id');
     if (sizeof($existingIds) != sizeof($varIds)) {
         $config->{"chart-dimensions"} = "[]";
         $config->{"form-config"}->{"variables-collection"} = [];
     }
     //possibly there could logo query parameter
     if (!empty($config) && !empty(Input::get('logo'))) {
         //there's logo query parameter, we want to display chart with different logo
         //find logo by name
         $logo = Logo::where('name', '=', Input::get('logo'))->first();
         if (!empty($logo)) {
             //set logo in config with logo from query parameter
             $config->{"second-logo"} = $logo->url;
         }
     }
     return $config;
 }
 public function editorData()
 {
     $data = new \StdClass();
     $data->chartTypes = ChartType::lists('name', 'id');
     $data->logos = Logo::lists('name', 'url');
     $query = DB::table("variables")->join('datasets', 'variables.fk_dst_id', '=', 'datasets.id')->join('dataset_categories', 'datasets.fk_dst_cat_id', '=', 'dataset_categories.id')->join('dataset_subcategories', 'datasets.fk_dst_subcat_id', '=', 'dataset_subcategories.id')->orderBy('dataset_categories.id', 'ASC')->orderBy('dataset_subcategories.id', 'ASC')->select('variables.name', 'variables.id', 'variables.unit', 'datasets.name as dataset', 'dataset_categories.name as category', 'dataset_subcategories.name as subcategory');
     $optgroups = [];
     foreach ($query->get() as $result) {
         if (!isset($optgroups[$result->subcategory])) {
             $optgroup = new \StdClass();
             $optgroup->name = $result->subcategory;
             $optgroup->variables = [];
             $optgroups[$result->subcategory] = $optgroup;
         }
         if ($result->name != $result->dataset) {
             $result->name = $result->dataset . " - " . $result->name;
         }
         $optgroups[$result->subcategory]->variables[] = $result;
     }
     $data->optgroups = $optgroups;
     return $data;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return response()->json(['status' => 'OK', 'data' => Logo::all()], 200);
 }
Beispiel #7
0
 public static function filtro($name, $url)
 {
     return Logo::nombre($name, $url)->orderBy('id', 'asc')->get();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Logo $logo, Request $request)
 {
     //delete database record
     $logo->delete();
     //delete actual file
     \File::delete($logo->url);
     Cache::flush();
     return redirect()->route('logos.index')->with('message', 'Logo deleted.');
 }
 /**
  * @param Request $request
  */
 public function profile_logo(Request $request)
 {
     $travel_company = Auth::travel_company_staff()->get()->travel_company;
     $destinationPath = null;
     if (App::environment() == 'local') {
         $destinationPath = base_path() . '/public/images/';
     } elseif (App::environment() == 'production') {
         $destinationPath = '/home/twokays/public_html/images/';
     }
     if ($request->file('file')->isValid()) {
         $file = $request->file('file');
         $ext = $file->getClientOriginalExtension();
         $destinationPath = $destinationPath;
         $fileName = str_slug($travel_company->name) . '_logo.' . $ext;
         $full_path = '/images/' . $fileName;
         $file->move($destinationPath, $fileName);
         // uploading file to given path
         $tcl = Logo::where('travel_company_id', $travel_company->id)->first();
         if (!$tcl) {
             Logo::create(['path' => $full_path, 'travel_company_id' => $travel_company->id]);
         } else {
             $tcl->update(['path' => $full_path]);
         }
         return $full_path;
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(FormatoEvidenciaRequest $request, $id)
 {
     $formatoEBan = FormatoEvidencia::findOrFail($id);
     //obtenemos el campo file definido en el formulario
     $file = $request->file('logo');
     $idLogo = 0;
     if ($file != null) {
         $image = Image::make($file);
         //cambiar tamaño
         $image->resize(100, 100);
         //obtenemos el nombre del archivo
         $nombre = $file->getClientOriginalName();
         //url de la ubicacion donde se guardara
         $public_path = public_path();
         $url = '/app/logos/' . $nombre;
         $idLogo = 0;
         //verificamos si el archivo existe y lo retornamos
         if (Storage::exists($nombre)) {
             $logoBD = Logo::filtro($nombre, $url);
             if ($logoBD->toArray() == null) {
                 $logoEBan = new Logo();
                 $logoEBan->nom_logo = $nombre;
                 $logoEBan->url = $url;
                 $logoEBan->save();
                 $logoBD = Logo::filtro($nombre, $url);
                 $idLogo = $logoBD->toArray()[0]['id'];
             } else {
                 $idLogo = $logoBD->toArray()[0]['id'];
             }
         } else {
             //indicamos que queremos guardar un nuevo archivo en el disco local
             // Guardar Original
             $image->save($public_path . $url);
             $logoBD = Logo::filtro($nombre, $url);
             if ($logoBD->toArray() == null) {
                 $logoEBan = new Logo();
                 $logoEBan->nom_logo = $nombre;
                 $logoEBan->url = $url;
                 $logoEBan->save();
                 $logoBD = Logo::filtro($nombre, $url);
                 $idLogo = $logoBD->toArray()[0]['id'];
             } else {
                 $idLogo = $logoBD->toArray()[0]['id'];
             }
         }
     } else {
         $idLogo = $formatoEBan->id_logo;
     }
     $formatoEBan->fill($request->all());
     $formatoEBan->nom_formato = strtoupper($request->get('nombre_formato'));
     $formatoEBan->encabezado_formato = $request->get('encabezado_formato');
     $formatoEBan->cuerpo_formato = $request->get('cuerpo_formato');
     $formatoEBan->id_logo = $idLogo;
     $formatoEBan->save();
     return Redirect::route('formatoEvidencia.index')->with('alert', 'Registro Actualizado con exito!');
 }