Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

120.2 #125

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open

120.2 #125

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Illuminate\Http\Exceptions\PostTooLargeException;
use Illuminate\Support\Facades\Response;

class Handler extends ExceptionHandler
{
Expand Down Expand Up @@ -37,4 +39,12 @@ public function register()
//
});
}
public function render($request, Throwable $exception)
{
if ($exception instanceof PostTooLargeException) {
return redirect()->back()->withErrors(['ssuccess' => "Imagem muito grande!"]);
}

return parent::render($request, $exception);
}
}
8 changes: 4 additions & 4 deletions app/Http/Controllers/FigmaMapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class FigmaMapController extends Controller
{


public function requestFigma($name, $campus){

$query = FigmaMap::query()->where('name', '=', $name)->where('campus', '=', $campus)->first();
Expand All @@ -31,18 +30,19 @@ public function requestFigma($name, $campus){
}

public function index(){
$data = FigmaMap::query()->where('name', '=', 'Principal')->get();
/* $data = FigmaMap::query()->where('name', '=', 'Principal')->get();
foreach ($data as $k => $v){
$campus = Information::siglaCampus($v['campus']);
$v['campus'] = $campus;
$data[$k] = $v;
}
} */
$data = FigmaMap::all();
return view('mapa_figma.index', ['data' => $data]);
}

public function edit(FigmaMap $figma_map){
$name = $figma_map->getAttribute('name');
$campus = $figma_map->getAttribute('campus');
$name = $figma_map->getAttribute('name');
$SVG = $this->requestFigma($name, $campus);
$xml = simplexml_load_string($SVG);
$viewbox = null;
Expand Down
41 changes: 41 additions & 0 deletions app/Http/Controllers/ImageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\FigmaMap;
use App\Models;
use WebPConvert\WebPConvert;

class ImageController extends Controller
{
public function upload(Request $request)
{
$path = $request->file('imagem')->store('img/geral');
$file = $request->file('imagem');
$extension = $file->getClientOriginalExtension();
$fileName = 'imagem_' . date('YmdHisv');
$file->move(public_path('img/geral'), $fileName.'.'.$extension);

$source = public_path('img/geral/').$fileName.'.'.$extension;
$destination = public_path('img/webp/').$fileName.'.webp';
$options = [];
WebPConvert::convert($source, $destination, $options);

return $fileName;
}

public function sliderUpload(Request $request, FigmaMap $figma_map)
{
$name = $figma_map->getAttribute('name');

$fileName = $this->upload($request);
$file = $request->file('imagem');
$extension = $file->getClientOriginalExtension();

$figma_map->image_link = $fileName.'.'.$extension;
$figma_map->save();

return redirect()->back()->with('success', "Imagem de $name atualizada com sucesso");
}
}
19 changes: 19 additions & 0 deletions app/Http/Controllers/LandingPageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Controllers;

use App\Models\FigmaMap;
use App\Http\Controllers\WebpSupportController;

class LandingPageController extends Controller
{
public function index()
{
$data = FigmaMap::all();

$webpController = new WebpSupportController;
$webpsupport = $webpController->support();

return view('landingpage', ['data' => $data, 'webpsupport' => $webpsupport]);
}
}
18 changes: 18 additions & 0 deletions app/Http/Controllers/WebpSupportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Http\Controllers;

use App\Models\FigmaMap;

class WebpSupportController extends Controller
{
public function support()
{
if( strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false ) { // webp is supported!
return TRUE;
}
else {
return FALSE;
}
}
}
2 changes: 1 addition & 1 deletion app/Models/FigmaMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class FigmaMap extends Model
use HasFactory;
protected $table = 'figma_maps';

protected $fillable = ['name', 'campus', 'file_name', 'file_key', 'node_id', 'viewport'];
protected $fillable = ['name', 'campus', 'file_name', 'file_key', 'node_id', 'viewport', 'image_link'];
}
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"buglinjo/laravel-webp": "^2.3",
"ccuffs/auth-iduffs": "^1.1",
"doctrine/dbal": "^3.6",
"erusev/parsedown": "^1.7",
Expand All @@ -23,6 +24,7 @@
"laravel/ui": "^3.4",
"league/html-to-markdown": "^5.1",
"livewire/livewire": "^2.11",
"rosell-dk/webp-convert": "^2.9",
"wireui/wireui": "^1.17"
},
"require-dev": {
Expand Down
Loading