-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c91f453
commit 2b75d33
Showing
91 changed files
with
11,543 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[docker-compose.yml] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
|
||
LOG_CHANNEL=stack | ||
LOG_DEPRECATIONS_CHANNEL=null | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
DB_DATABASE=laravel | ||
DB_USERNAME=root | ||
DB_PASSWORD= | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
FILESYSTEM_DRIVER=local | ||
QUEUE_CONNECTION=sync | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
MEMCACHED_HOST=127.0.0.1 | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=smtp | ||
MAIL_HOST=mailhog | ||
MAIL_PORT=1025 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS=null | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
AWS_USE_PATH_STYLE_ENDPOINT=false | ||
|
||
PUSHER_APP_ID= | ||
PUSHER_APP_KEY= | ||
PUSHER_APP_SECRET= | ||
PUSHER_APP_CLUSTER=mt1 | ||
|
||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
* text=auto | ||
|
||
*.blade.php diff=html | ||
*.css diff=css | ||
*.html diff=html | ||
*.md diff=markdown | ||
*.php diff=php | ||
|
||
/.github export-ignore | ||
CHANGELOG.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
docker-compose.override.yml | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
/.idea | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
php: | ||
preset: laravel | ||
version: 8 | ||
disabled: | ||
- no_unused_imports | ||
finder: | ||
not-name: | ||
- index.php | ||
- server.php | ||
js: | ||
finder: | ||
not-name: | ||
- webpack.mix.js | ||
css: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* Define the application's command schedule. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
*/ | ||
protected function schedule(Schedule $schedule) | ||
{ | ||
// $schedule->command('inspire')->hourly(); | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
* | ||
* @return void | ||
*/ | ||
protected function commands() | ||
{ | ||
$this->load(__DIR__.'/Commands'); | ||
|
||
require base_path('routes/console.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
use Throwable; | ||
|
||
class Handler extends ExceptionHandler | ||
{ | ||
/** | ||
* A list of the exception types that are not reported. | ||
* | ||
* @var array<int, class-string<Throwable>> | ||
*/ | ||
protected $dontReport = [ | ||
// | ||
]; | ||
|
||
/** | ||
* A list of the inputs that are never flashed for validation exceptions. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $dontFlash = [ | ||
'current_password', | ||
'password', | ||
'password_confirmation', | ||
]; | ||
|
||
/** | ||
* Register the exception handling callbacks for the application. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->reportable(function (Throwable $e) { | ||
// | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | ||
use Illuminate\Foundation\Bus\DispatchesJobs; | ||
use Illuminate\Foundation\Validation\ValidatesRequests; | ||
use Illuminate\Routing\Controller as BaseController; | ||
|
||
class Controller extends BaseController | ||
{ | ||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Category; | ||
use App\Models\Product; | ||
use Exception; | ||
use Illuminate\Http\Request; | ||
|
||
class ProductController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index() | ||
{ | ||
$products = Product::with('categoria')->orderBy('nome')->get(); | ||
|
||
return view('products.index', [ | ||
'products' => $products | ||
]); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function create() | ||
{ | ||
|
||
try { | ||
$categories = Category::orderBy('nome')->get(); | ||
|
||
return view('products.form-create', [ | ||
'categories' => $categories | ||
]); | ||
} catch (Exception $ex) { | ||
return redirect() | ||
->back() | ||
->with('error', $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
try { | ||
|
||
if (!$request->nome) { | ||
throw new Exception('O campo Nome não foi informado'); | ||
} | ||
|
||
if (!$request->id_categoria) { | ||
throw new Exception('O campo Categoria não foi informado'); | ||
} | ||
|
||
$product = Product::create([ | ||
'nome' => $request->nome, | ||
'descricao' => $request->descricao, | ||
'id_categoria' => $request->id_categoria | ||
]); | ||
|
||
if (!$product) { | ||
throw new Exception('Não foi possível cadastrar o produto. Por favor, tente novamente'); | ||
} | ||
|
||
return redirect() | ||
->back() | ||
->with('success', 'Produto "' . $product->nome . '" Cadastrado com sucesso'); | ||
} catch (Exception $ex) { | ||
return redirect() | ||
->back() | ||
->withInput() | ||
->with('error', $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @param \App\Models\Product $product | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function show(Product $product) | ||
{ | ||
try { | ||
|
||
$product->load('categoria'); | ||
|
||
$response['error'] = true; | ||
$response['product'] = $product; | ||
} catch (Exception $ex) { | ||
$response['error'] = true; | ||
$response['msg'] = $ex->getMessage(); | ||
} finally { | ||
return json_encode($response); | ||
} | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \App\Models\Product $product | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function edit(Product $product) | ||
{ | ||
try { | ||
$categories = Category::orderBy('nome')->get(); | ||
|
||
return view('products.form-edit', [ | ||
'product' => $product, | ||
'categories' => $categories | ||
]); | ||
} catch (Exception $ex) { | ||
return redirect() | ||
->back() | ||
->withInput() | ||
->with('error', $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param \App\Models\Product $product | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function update(Request $request, Product $product) | ||
{ | ||
try { | ||
|
||
if (!$request->nome) { | ||
throw new Exception('O campo Nome não foi informado'); | ||
} | ||
|
||
if (!$request->id_categoria) { | ||
throw new Exception('O campo Categoria não foi informado'); | ||
} | ||
|
||
$product->update([ | ||
'nome' => $request->nome, | ||
'descricao' => $request->descricao, | ||
'id_categoria' => $request->id_categoria | ||
]); | ||
|
||
if (!$product) { | ||
throw new Exception('Não foi possível atualizar o produto. Por favor, tente novamente'); | ||
} | ||
|
||
return redirect() | ||
->back() | ||
->with('success', 'Produto "' . $product->nome . '" Atualizado com sucesso'); | ||
} catch (Exception $ex) { | ||
return redirect() | ||
->back() | ||
->withInput() | ||
->with('error', $ex->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \App\Models\Product $product | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function destroy(Product $product) | ||
{ | ||
try { | ||
if (!$product->delete()) { | ||
throw new Exception('Não foi possível remover o produto. Por favor, tente novamente'); | ||
} | ||
|
||
$response['error'] = false; | ||
$response['msg'] = 'Produto "' . $product->nome . '" Removido com sucesso'; | ||
} catch (Exception $ex) { | ||
$response['error'] = true; | ||
$response['msg'] = $ex->getMessage(); | ||
} finally { | ||
return json_encode($response); | ||
} | ||
} | ||
} |
Oops, something went wrong.