Compare commits

..

No commits in common. "51030b85df070574719c6fde2aa03839710438e9" and "fc644fa2216c23c7c067df6df1a8647b882db081" have entirely different histories.

303 changed files with 1439 additions and 2395 deletions

View File

@ -3,7 +3,6 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
FRONTEND_URL=http://localhost:3444
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
@ -51,5 +50,3 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
WEBHOOK_NEWS=""

1
.gitignore vendored
View File

@ -4,7 +4,6 @@
/storage/*.key
/vendor
.env
.env.local
.env.backup
.phpunit.result.cache
Homestead.json

View File

@ -1,3 +1,64 @@
# API
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
## Requerimentos
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
### Premium Partners
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
- **[OP.GG](https://op.gg)**
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
- **[Lendio](https://lendio.com)**
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -16,7 +16,6 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('telescope:prune')->cron('0 0 */21 * *');
}
/**

View File

@ -2,7 +2,7 @@
namespace App\Exceptions;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\App;
use Illuminate\Database\QueryException;
@ -51,12 +51,13 @@ class Handler extends ExceptionHandler
private function messageCustom(\Throwable $ex): array
{
$messageCustom = [];
$class_exceptions = [
AuthorizationException::class => fn ($e) => [
'Forbidden',
Response::HTTP_FORBIDDEN
'Unauthorized',
Response::HTTP_UNAUTHORIZED
],
AuthenticationException::class => fn ($e) => [
@ -114,6 +115,7 @@ class Handler extends ExceptionHandler
];
}
return $messageCustom;
}
@ -133,7 +135,7 @@ class Handler extends ExceptionHandler
Log::error($message);
return false; //https://laravel.com/docs/9.x/errors#reporting-exceptions
return false;
});
}
@ -148,6 +150,6 @@ class Handler extends ExceptionHandler
{
[$message, $status_code] = $this->messageCustom($ex);
return ResponseJsonMessage::withError($message, $status_code);
return ResponseJson::error($message, $status_code);
}
}

View File

@ -5,20 +5,20 @@ namespace App\Helpers;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
class ResponseJsonMessage
class ResponseJson
{
public static function withMessage(string $message, $status_code = Response::HTTP_OK): JsonResponse
public static function message(string $message, $status_code = Response::HTTP_OK): JsonResponse
{
return response()->json(compact('message'), $status_code);
}
public static function withData(mixed $data, $status_code = Response::HTTP_OK): JsonResponse
public static function data(mixed $data, $status_code = Response::HTTP_OK): JsonResponse
{
return response()->json(compact('data'), $status_code);
}
public static function withError(mixed $error, int $status_code): JsonResponse
public static function error(mixed $error, int $status_code): JsonResponse
{
return response()->json(compact('error'), $status_code);
}

View File

@ -4,38 +4,51 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Http\Requests\StoreAboutUsRequest;
use App\Http\Resources\AboutUsResource;
use App\Repositories\AboutUs\AboutUsContractInterface;
use App\Traits\ApiResponse;
use Illuminate\Http\Response;
class AboutUsController extends Controller
{
use ApiResponse;
public function __construct(
protected AboutUsContractInterface $aboutUsContract
) {
}
){}
public function index()
{
$response = $this->aboutUsContract->all();
return ResponseJsonMessage::withData($response);
try {
$response = $this->aboutUsContract->all();
return (new AboutUsResource($response))
->response()
->setStatusCode(Response::HTTP_OK);
} catch (\Exception $ex) {
return $this->errorResponse(false, $ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function store(StoreAboutUsRequest $aboutUsRequest)
{
try {
$about = $this->aboutUsContract->max('id');
$about = $this->aboutUsContract->max('id');
if ($about !== null) {
$response = $this->aboutUsContract->update($aboutUsRequest->validated(), $about);
} else {
$response = $this->aboutUsContract->create($aboutUsRequest->validated());
if ($about !== null)
{
$response = $this->aboutUsContract->update($aboutUsRequest->validated(), $about);
} else {
$response = $this->aboutUsContract->create($aboutUsRequest->validated());
}
return (new AboutUsResource($response))
->response()
->setStatusCode(Response::HTTP_ACCEPTED);
} catch (\Exception $ex) {
return $this->errorResponse(false, $ex->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
}
return ResponseJsonMessage::withData($response);
}
}
}

View File

@ -3,7 +3,7 @@
namespace App\Http\Controllers\Auth;
use App\Models\User;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Http\Controllers\Controller;
use App\Http\Requests\LoginResquest;
@ -43,6 +43,6 @@ class AuthController extends Controller
$user?->currentAccessToken()?->delete();
return ResponseJsonMessage::withMessage('Token Revoked.');
return ResponseJson::message('Token Revoked.');
}
}

View File

@ -2,52 +2,57 @@
namespace App\Http\Controllers\Auth;
use App\Helpers\ResponseJsonMessage;
use App\Http\Requests\ForgotPasswordRequest;
use App\Mail\ResetPassword;
use App\Models\User;
use App\Traits\ApiResponse;
use Carbon\Carbon;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;
class ForgotPasswordController extends Controller
{
use ApiResponse;
public function __invoke(ForgotPasswordRequest $request)
{
$email = $request->validated('email');
$verify = User::where('email', $request->all()['email'])->exists();
$is_email = User::where('email', $email)->exists();
if ($verify) {
if (!$is_email) return ResponseJsonMessage::withError(
'Esse e-mail não existe no nosso sistema',
Response::HTTP_BAD_REQUEST
);
$verify2 = DB::table('password_resets')->where([
['email', $request->all()['email']]
]);
DB::table('password_resets')->where('email', $email)->delete();
if ($verify2->exists()) {
$verify2->delete();
}
$token = random_int(100000, 999999);
$token = random_int(100000, 999999);
$password_reset = DB::table('password_resets')->insert([
'email' => $request->all()['email'],
'token' => $token,
'created_at' => Carbon::now()
DB::table('password_resets')->insert([
'email' => $email,
'token' => $token,
'created_at' => Carbon::now()
]);
]);
if ($password_reset) {
$sendMail = Mail::to($request->all()['email'])->send(new ResetPassword($token));
Mail::to($email)->send(new ResetPassword($token));
return ResponseJsonMessage::withMessage("Verifique seu e-mail");
return $this->successResponse(true, "Please check your email for a 6 digit pin", 200);
}
} else {
return $this->errorResponse(false, "This email does not exist", 400);
}
}
public function verifyPin(Request $request)
{
}
}

View File

@ -2,17 +2,17 @@
namespace App\Http\Controllers\Auth;
use App\Models\User;
use App\Helpers\ResponseJsonMessage;
use App\Http\Controllers\Controller;
use App\Http\Requests\ResetPasswordRequest;
use Illuminate\Support\Carbon;
use App\Models\User;
use App\Traits\ApiResponse;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class ResetPasswordController extends Controller
{
use ApiResponse;
public function __invoke(ResetPasswordRequest $resetPasswordRequest)
{
@ -24,12 +24,11 @@ class ResetPasswordController extends Controller
if ($check->exists()) {
$difference = Carbon::now()->diffInSeconds($check->first()->created_at);
if ($difference > 3600) {
return ResponseJsonMessage::withError("Token Expired", 400);
return $this->errorResponse(false, "Token Expired", 400);
}
DB::table('password_resets')->where([
$delete = DB::table('password_resets')->where([
['email', $resetPasswordRequest->email],
['token', $resetPasswordRequest->token],
])->delete();
@ -40,7 +39,11 @@ class ResetPasswordController extends Controller
'password' => $resetPasswordRequest->password
]);
ResponseJsonMessage::withData($user);
return $this->successResponse([
'user' => $user
],
"You can now reset your password",
200);
} else {
return $this->errorResponse(false, "Invalid token", 401);

View File

@ -4,14 +4,16 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Traits\ApiResponse;
use App\Helpers\ResponseJson;
use App\Repositories\DadosCadastrais\DadosCadastraisContractInterface;
use Illuminate\Http\Request;
class ClientController extends Controller
{
use ApiResponse;
public function __construct(
protected DadosCadastraisContractInterface $dadosCadastraisContract
) {
@ -21,6 +23,6 @@ class ClientController extends Controller
{
$response = $this->dadosCadastraisContract->search($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -4,16 +4,16 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Repositories\Economy\EconomyContractInterface;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class EconomyController extends Controller
{
use ApiResponse;
public function __construct(
protected EconomyContractInterface $economyContract
@ -24,14 +24,14 @@ class EconomyController extends Controller
{
$response = $this->economyContract->search($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function grossAnnualEconomy(Request $request): JsonResponse
{
$response = $this->economyContract->getGrossAnnualEconomy($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function grossMonthlyEconomy(Request $request): JsonResponse
@ -39,20 +39,20 @@ class EconomyController extends Controller
$response = $this->economyContract->getGrossMonthlyEconomy($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function captiveMonthlyEconomy(Request $request): JsonResponse
{
$response = $this->economyContract->getCaptiveMonthlyEconomy($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function costMWhEconomy(Request $request): JsonResponse
{
$response = $this->economyContract->getCostMWhEconomy($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Traits\ApiResponse;
use App\Helpers\ResponseJson;
use App\Repositories\Faqs\FaqContractInterface;
use Illuminate\Http\JsonResponse;
@ -14,7 +14,7 @@ use Illuminate\Http\Response;
class FaqController extends Controller
{
use ApiResponse;
public function __construct(
protected FaqContractInterface $faq
@ -25,34 +25,34 @@ class FaqController extends Controller
{
$response = $this->faq->all();
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function store(Request $notificationRequest): JsonResponse
{
$response = $this->faq->create($notificationRequest->all());
return ResponseJsonMessage::withData($response, Response::HTTP_CREATED);
return ResponseJson::data($response, Response::HTTP_CREATED);
}
public function show(int $id): JsonResponse
{
$response = $this->faq->find($id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function update(Request $request, $id): JsonResponse
{
$response = $this->faq->update($request->all(), $id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function destroy($id): JsonResponse
{
$response = $this->faq->destroy($id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -4,23 +4,22 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Http\Requests\UploadInfoSectorialRequest;
use App\Models\InfoSectorial;
use App\Traits\ApiResponse;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class InfoSectorialController extends Controller
{
use ApiResponse;
public function updateFile(UploadInfoSectorialRequest $uploadInfoSectorialRequest)
{
$data = $uploadInfoSectorialRequest->all();
if (!$uploadInfoSectorialRequest->hasFile('file')) {
return $this->errorResponse(false, '', 500);
return $this->errorResponse( false, '', 500);
}
$file = $uploadInfoSectorialRequest->file('file');
@ -28,19 +27,24 @@ class InfoSectorialController extends Controller
$data['name'] = Str::of($file->getClientOriginalName())->explode('.')->offsetGet(0);
$data['uid'] = Str::of($file->hashName())->explode('.')->offsetGet(0);
$extension = $file->getClientOriginalExtension();
$data['path'] = $file->storeAs('pdf', $data['uid'] . ".{$extension}", 's3');
$data['path'] = $file->storeAs('pdf', $data['uid'].".{$extension}", 's3');
return InfoSectorial::query()->create($data);
}
public function download()
{
$created_at = InfoSectorial::max('created_at');
$created_at = InfoSectorial::query()->max('created_at');
$data = InfoSectorial::where('created_at', '=', $created_at)->first();
$data = InfoSectorial::query()->where('created_at', '=', $created_at)->first();
return ResponseJsonMessage::withData(
!empty($data) ? Storage::disk('s3')->url($data->path) : ''
);
if (!Storage::disk('s3')->exists($data->path))
{
return $this->errorResponse( false, '', 500);
}
$path['path'] = Storage::disk('s3')->url($data->path);
return response()->json($path, 200);
}
}

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use Illuminate\Support\Arr;
use Illuminate\Support\Carbon;
@ -29,6 +29,6 @@ class NewsController extends Controller
)
);
return ResponseJsonMessage::withData($resource);
return ResponseJson::data($resource);
}
}

View File

@ -4,10 +4,10 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Http\Requests\StoreNotificationRequest;
use App\Repositories\Notifications\NotificationContractInterface;
use App\Traits\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
@ -15,7 +15,7 @@ use Illuminate\Http\Response;
class NotificationController extends Controller
{
use ApiResponse;
public function __construct(
protected NotificationContractInterface $notification
@ -26,7 +26,7 @@ class NotificationController extends Controller
{
$response = $this->notification->all();
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function store(StoreNotificationRequest $request): JsonResponse
@ -34,34 +34,34 @@ class NotificationController extends Controller
$response = $this->notification->create($request->validated());
$response->users()->sync($request->input('users.*.user_id', []));
return ResponseJsonMessage::withData($response, Response::HTTP_CREATED);
return ResponseJson::data($response, Response::HTTP_CREATED);
}
public function show(int $id): JsonResponse
{
$response = $this->notification->find($id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function update(Request $request, $id): JsonResponse
{
$response = $this->notification->update($request->all(), $id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function destroy($id): JsonResponse
{
$response = $this->notification->destroy($id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function notify()
{
$response = $this->notification->getNotify();
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -5,15 +5,15 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\Helpers;
use App\Helpers\ResponseJsonMessage;
use App\Traits\ApiResponse;
use App\Helpers\ResponseJson;
use App\Repositories\DadosTe\DadosTeContractInterface;
use Illuminate\Http\Request;
class OperationSummaryController extends Controller
{
use ApiResponse;
public function __construct(
protected DadosTeContractInterface $dadosTeContract
@ -25,13 +25,13 @@ class OperationSummaryController extends Controller
$response = $this->dadosTeContract->search($request->all(), true);
$response = Helpers::orderByDate($response, 'm/Y');
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function operationSummary(Request $request)
{
$response = $this->dadosTeContract->getOperationSummary($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -5,8 +5,8 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\Helpers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Traits\ApiResponse;
use App\Repositories\Pld\PldContractInterface;
use Illuminate\Http\Request;
@ -14,7 +14,7 @@ use Illuminate\Http\Request;
class PldController extends Controller
{
use ApiResponse;
public function __construct(
protected PldContractInterface $pldContract
@ -26,34 +26,34 @@ class PldController extends Controller
$response = $this->pldContract->search($request->all());
$response = Helpers::orderByDate($response, 'm/Y', 'mes_ref');
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function overviewByRegion()
{
$response = $this->pldContract->getOverviewByRegion();
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function listConsumption(Request $request)
{
$response = $this->pldContract->getListConsumption($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function consumptionByDaily(Request $request)
{
$response = $this->pldContract->getConsumptionByDaily($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function consumptionBySchedule(Request $request)
{
$response = $this->pldContract->getConsumptionBySchedule($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -4,17 +4,17 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Http\Resources\TelemetryResource;
use App\Repositories\Med5min\Med5minContractInterface;
use App\Traits\ApiResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class TelemetryController extends Controller
{
use ApiResponse;
public function __construct(
protected Med5minContractInterface $med5minContract
@ -25,20 +25,20 @@ class TelemetryController extends Controller
{
$response = $this->med5minContract->search($request->all());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function discretization(Request $request)
{
$response = $this->med5minContract->getDiscretization($request->all(), $request->getPathInfo());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
public function download(Request $request)
{
$response = $this->med5minContract->getDiscretization($request->all(), $request->getPathInfo());
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
}

View File

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use App\Helpers\ResponseJsonMessage;
use App\Helpers\ResponseJson;
use App\Http\Requests\ImportUsersWithSmartUsersRequest;
use App\Traits\ApiResponse;
use App\Http\Requests\StoreUserRequest;
use App\Imports\UsersWithSmartUsersImport;
use App\Repositories\Users\UserContractInterface;
@ -20,6 +20,8 @@ use Maatwebsite\Excel\Facades\Excel;
class UserController extends Controller
{
use ApiResponse;
public function __construct(
protected UserContractInterface $user
) {
@ -34,7 +36,7 @@ class UserController extends Controller
{
$response = $this->user->getOrdered();
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
/**
@ -58,7 +60,7 @@ class UserController extends Controller
$response = $this->user->create($data);
$response->roles()->sync($data['role']);
return ResponseJsonMessage::withData($response, Response::HTTP_CREATED);
return ResponseJson::data($response, Response::HTTP_CREATED);
}
/**
@ -71,7 +73,7 @@ class UserController extends Controller
{
$response = $this->user->find($id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
/**
@ -87,7 +89,7 @@ class UserController extends Controller
$data['password'] = $request->password;
$response = $this->user->update($data, $id);
return ResponseJsonMessage::withData($response);
return ResponseJson::data($response);
}
/**
@ -98,9 +100,9 @@ class UserController extends Controller
*/
public function destroy($id): JsonResponse
{
$this->user->destroy($id);
$response = $this->user->destroy($id);
return ResponseJsonMessage::withMessage('Usuário deletado!');
return response()->json($response, Response::HTTP_NO_CONTENT);
}
public function importUserControll(ImportUsersWithSmartUsersRequest $request): JsonResponse
@ -124,7 +126,7 @@ class UserController extends Controller
disk: $disk,
);
return ResponseJsonMessage::withMessage('Dados importados com sucesso!', Response::HTTP_CREATED);
return ResponseJson::message('Dados importados com sucesso!', Response::HTTP_CREATED);
} catch (\Throwable $th) {
throw $th;
} finally {

View File

@ -72,19 +72,13 @@ class UsersWithSmartUsersImport implements ToCollection
? $this->files_paths[$client_id]
: '';
/**
* @var ?\App\Models\User $user
*/
$user = User::create(\compact(
User::create(\compact(
'client_id',
'name',
'email',
'password',
'profile_picture'
));
$user?->roles()?->sync([2]);
}
private function createSmartUserAccess(Collection $row, DadosCadastrais $client, string $email): void
@ -96,18 +90,13 @@ class UsersWithSmartUsersImport implements ToCollection
? $this->files_paths[$client_id]
: '';
/**
* @var ?\App\Models\User $user
*/
$user = User::create(\compact(
User::create(\compact(
'client_id',
'name',
'email',
'password',
'profile_picture'
));
$user?->roles()?->sync([2]);
}
private function uploadProfilePictures()

View File

@ -3,6 +3,7 @@
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

View File

@ -1,30 +0,0 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class TempMail extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public string $name, public string $password, public bool $has_password = true)
{
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject("Recuperação de Senha")->markdown('emails.temp-email');
}
}

View File

@ -1,65 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
Telescope::filter(function (IncomingEntry $entry) {
if ($this->app->environment('local')) {
return true;
}
return $entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function () {
return in_array(request()->query('email'), [
'smart_admin_monitor@energiasmart.com.br'
]);
});
}
}

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Repositories\DadosCadastrais;
use App\Models\DadosCadastrais;
use App\Models\DadosTe;
use App\Repositories\AbstractRepository;

View File

@ -7,11 +7,14 @@ namespace App\Repositories\Economy;
use App\Helpers\Helpers;
use App\Models\Economy;
use App\Repositories\AbstractRepository;
use Carbon\Carbon;
use DateInterval;
use DatePeriod;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class EconomyRepository extends AbstractRepository implements EconomyContractInterface
{
@ -45,8 +48,8 @@ class EconomyRepository extends AbstractRepository implements EconomyContractInt
];
return $this->execute($params, $field)
->where(
DB::raw("TO_DATE(economia.mes, 'YYMM')"),
->where(DB::raw(
"TO_DATE(economia.mes, 'YYMM')"),
">=",
DB::raw("TO_DATE(TO_CHAR(current_date , 'YYYY-12-01'), 'YYYY-MM-DD') - interval '1' year"))
->where(function ($query) {

View File

@ -17,9 +17,7 @@ class NotificationRepository extends AbstractRepository implements NotificationC
public function getNotify(): int
{
return Notifications::query()
->with('users')
->whereRelation('users', 'id', '=', auth()->id())
->count();
return Notifications::query()->with('users')
->whereRelation('users', 'id', '=', auth()->id())->count();
}
}
}

View File

@ -213,23 +213,20 @@ class PldRepository extends AbstractRepository implements PldContractInterface
}
protected static function max($query){
return $query->max(DB::raw("value")) ?? 0;
return $query->max(DB::raw("value"));
}
protected static function min($query){
return $query->min(DB::raw("value")) ?? 0;
return $query->min(DB::raw("value"));
}
protected static function standardDeviation($query): float|bool
{
/**
* @var \Illuminate\Support\Collection $devs_pad
*/
$devs_pad = $query->addSelect([
DB::raw("AVG(valor) as desv_pad")
])->get();
$array = $query->addSelect([
DB::raw("AVG(valor)as desv_pad")
])->get()->toArray();
return $devs_pad->count() > 2 ? \stats_standard_deviation($devs_pad->pluck('desv_pad')->toArray()) : 0;
return stats_standard_deviation(collect($array)->pluck('desv_pad')->all());
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Traits;
use Illuminate\Http\JsonResponse;
trait ApiResponse
{
protected function successResponse ($data, string $message = null, int $code = 200): JsonResponse
{
return response()->json([
'status' => 'Success',
'message' => $message,
'data' => $data
], $code);
}
protected function errorResponse ($data, string $message, int $code): JsonResponse
{
return response()->json([
'status' => 'Error',
'message' => $message,
'data' => $data
], $code);
}
}

View File

@ -14,7 +14,6 @@
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.11",
"laravel/sanctum": "^2.14.1",
"laravel/telescope": "^4.17",
"laravel/tinker": "^2.7",
"league/flysystem-aws-s3-v3": "^3.0",
"maatwebsite/excel": "^3.1",
@ -53,7 +52,7 @@
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"create-env": [
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"generate-key": [
@ -61,24 +60,22 @@
],
"cached": [
"@php artisan optimize --ansi",
"@php artisan config:cache --ansi",
"@php artisan route:cache --ansi",
"@php artisan view:clear --ansi",
"@php artisan view:cache --ansi",
"@php artisan event:cache --ansi",
"@php artisan package:discover --ansi"
"@php artisan route:clear --ansi",
"@php artisan event:cache --ansi"
],
"clear-cached": [
"@php artisan optimize:clear --ansi",
"@php artisan optimize:clear",
"@php artisan cache:clear --ansi",
"@php artisan view:clear --ansi",
"@php artisan route:clear --ansi",
"@php artisan event:clear --ansi",
"@php artisan config:clear --ansi"
"@php artisan config:clear --ansi",
"@php artisan schedule:clear-cache --ansi"
],
"queue": "@php artisan queue:listen --tries=2 --backoff=10 --timeout=60",
"schedule": "@php artisan schedule:work",
"authorized-files": "sudo chown -R www-data:www-data storage/ storage/framework/cache storage/framework/cache/data bootstrap/cache/ public/ && sudo chown -R :www-data storage/",
"dev": "@php artisan serve --host=0.0.0.0 --port=8181"
"authorized-files": "sudo chown -R www-data:www-data storage/ bootstrap/cache/ public/ && sudo chown -R :www-data storage/",
"dev": "@php artisan serve --host=0.0.0.0 --port=8080 --ansi"
},
"extra": {
"laravel": {

2513
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -198,7 +198,6 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
/*
* Laravel Auditing

View File

@ -1,189 +0,0 @@
<?php
use Laravel\Telescope\Http\Middleware\Authorize;
use Laravel\Telescope\Watchers;
return [
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => env('TELESCOPE_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => env('TELESCOPE_PATH', 'telescope'),
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'pgsql'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Allowed / Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'only_paths' => [
// 'api/*'
],
'ignore_paths' => [
'livewire*',
'nova-api*',
'pulse*',
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
Watchers\CacheWatcher::class => [
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
'hidden' => [],
],
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => [
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],
Watchers\EventWatcher::class => [
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
'ignore' => [],
],
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => [
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
'level' => 'error',
],
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
'hydrations' => true,
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
'ignore_http_methods' => [],
'ignore_status_codes' => [],
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
],
];

12
insertEconomy.php Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

BIN
public/images/180312221.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

BIN
public/images/220127210.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Some files were not shown because too many files have changed in this diff Show More