first commit

This commit is contained in:
2026-01-13 20:57:58 -06:00
commit afd9118d1e
239 changed files with 49001 additions and 0 deletions

15
.editorconfig Normal file
View File

@@ -0,0 +1,15 @@
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]
indent_size = 2

44
.env.example Normal file
View File

@@ -0,0 +1,44 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
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
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
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}"

5
.gitattributes vendored Normal file
View File

@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

12
.gitignore vendored Normal file
View File

@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

BIN
.rnd Normal file

Binary file not shown.

13
.styleci.yml Normal file
View File

@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

64
app.yaml Normal file
View File

@@ -0,0 +1,64 @@
runtime: php # language of the app
env: flex # let app engine know we use flexible environment
runtime_config:
document_root: public #folder where index.php is
# Ensure we skip ".env", which is only for local development
skip_files:
- .env #we want to skip this to make sure we dont mess stuff up on the server
env_variables:
APP_NAME: JobHero
APP_ENV: production
APP_URL: https://ichamba-1562349005909.uc.r.appspot.com
APP_KEY: base64:PcEmB+UyS58h/Rg3EbYvZwOdbuQPNJkdpmAmmUqisXc=
APP_DEBUG: false
DB_CONNECTION: mysql
DB_HOST: localhost
DB_DATABASE: ichamba
DB_USERNAME: root
DB_PASSWORD: kcy14thngsvv1
DB_SOCKET: "/cloudsql/ichamba-1562349005909:us-central1:ichamba-db"
CACHE_DRIVER: file
SESSION_DRIVER: cookie
SESSION_SECURE_COOKIE: true
MAIL_FROM_ADDRESS: info@jobheroglobal.com
MAIL_FROM_NAME: JobHero
MAIL_DRIVER: smtp
MAIL_HOST: smtp.mailgun.org
MAIL_PORT: 587
MAIL_USERNAME: postmaster@jobheroglobal.com
MAIL_PASSWORD: c1e3740d6639848eb247d5cbea9d2e62-64574a68-fe0c65f3
MAIL_ENCRYPTION: tls
FACEBOOK_CLIENT_ID: 342718733071161
FACEBOOK_CLIENT_SECRET: 70c28c21e1dd554bc56e976ca5a026b9
FACEBOOK_CALLBACK_URL: https://ichamba-1562349005909.appspot.com/auth/facebook/callback
GOOGLE_CLIENT_ID: 679874302148-d2l085q04i4d6pt3hhac2rbfm14js7e5.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET: VRNEFsGO8KkreSeC132aFDYU
GOOGLE_CALLBACK_URL: https://ichamba-1562349005909.appspot.com/auth/google/callback
RECAPTCHA_V3_SECRET_KEY: 6Len0CwbAAAAADHR_Hphs2bros58vq2Yoav57NPs
RECAPTCHA_V3_SITE_KEY: 6Len0CwbAAAAABE_elzeHQ-Aaez7AdnsD0MebI1x
SECRET: vktxm0tRk6Hvh3fnbSfDMe6We1nQxKCKPnv9Wq5S
PASS: wBIIKuDbrxNKzQhAUGiZLoaoQ4MichAN3wP2AP7B
OPENPAY_ID: m9k4beuso5az0wjqztvt
OPENPAY_APIKEY: sk_0eb5d4072ce64a189c1387a423c7d730
GOOGLE_VISION_PROJECT_ID : ichamba-1562349005909
GOOGLE_CLOUD_PROJECT_ID: ichamba-1562349005909
GOOGLE_CLOUD_STORAGE_BUCKET: ichamba-1562349005909.appspot.com
automatic_scaling:
min_num_instances: 1
beta_settings:
# for Cloud SQL, set this value to the Cloud SQL connection name,
# e.g. "project:region:cloudsql-instance"
cloud_sql_instances: "ichamba-1562349005909:us-central1:ichamba-db"

42
app/Console/Kernel.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* 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');
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}

View File

@@ -0,0 +1,219 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Verify_accounts;
use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Socialite;
use Route;
use Config;
class AuthController extends Controller
{
public function login(Request $request) {
$request->validate([
'email' => 'required|string|email',
'password' => 'required|string',
//'remember_me' => 'boolean'
]);
$credentials = request(['email', 'password']);
if(!Auth::attempt($credentials))
return response()->json([
'message' => 'Unauthorized'
], 401);
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
if ($request->remember_me)
$token->expires_at = Carbon::now()->addWeeks(1);
$token->save();
return response()->json([
'access_token' => $tokenResult->accessToken,
'token_type' => 'Bearer',
'expires_at' => Carbon::parse(
$tokenResult->token->expires_at
)->toDateTimeString(),
'userid' => $user->id,
'role' => $user->role_id,
'verified' => $user->phone_verified_at,
'reported' => $user->reported
]);
}
public function fb(Request $request)
{
$params = [
'grant_type' => 'social',
'client_id' => '2', // it should be password grant client
'client_secret' => config('app.secret'),
'provider' => 'facebook',
'access_token' => $request->access_token // access token from provider
];
$requestToken = Request::create("/oauth/token", "POST", $params);
$response = app()->handle($requestToken);
$json = json_decode($response->content(), true);
$user = User::where('social_id', $request->social_id) -> first();
$frontend = json_encode([
'token_type' => $json['token_type'],
'expires_at' => $json['expires_in'],
'access_token' => $json['access_token'],
'userid' => $user->id,
'role' => $user->role_id,
'verified' => $user->phone_verified_at,
'reported' => $user->reported
]);
return $frontend;
}
public function google(Request $request)
{
$params = [
'grant_type' => 'social',
'client_id' => '2', // it should be password grant client
'client_secret' => config('app.secret'),
'provider' => 'google',
'access_token' => $request->access_token // access token from provider
];
$requestToken = Request::create("/oauth/token", "POST", $params);
$response = app()->handle($requestToken);
$json = json_decode($response->content(), true);
$user = User::where('social_id', $request->social_id) -> first();
$frontend = json_encode([
'token_type' => $json['token_type'],
'expires_at' => $json['expires_in'],
'access_token' => $json['access_token'],
'userid' => $user->id,
'role' => $user->role_id,
'verified' => $user->phone_verified_at,
'reported' => $user->reported
]);
return $frontend;
}
public function apple(Request $request)
{
$params = [
'grant_type' => 'social',
'client_id' => '2', // it should be password grant client
'client_secret' => config('app.secret'),
'provider' => 'apple',
'access_token' => $request->access_token // access token from provider
];
$requestToken = Request::create("/oauth/token", "POST", $params);
$response = app()->handle($requestToken);
$json = json_decode($response->content(), true);
$user = User::where('social_id', $request->social_id) -> first();
$frontend = json_encode([
'token_type' => $json['token_type'],
'expires_at' => $json['expires_in'],
'access_token' => $json['access_token'],
'userid' => $user->id,
'role' => $user->role_id,
'verified' => $user->phone_verified_at,
'reported' => $user->reported
]);
return $frontend;
}
public function register(Request $request)
{
$rules = [
'name' => 'required|string|regex:/(^[a-zA-Z\s ÑñÁáÉéÍíÓóÚúÜü]+$)+/',
'email' => 'required|string|email|unique:users',
'phone' => 'required|numeric',
'password' => 'required|string',
'secret' => 'required|string'
];
$messages = [
'email.unique' => 'Correo electronico ya registrado',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return response()->json([
'message' => $validator->messages()->first()
], 422);
}
if ($request->secret == config('app.pass')) {
/**$verify = new Verify_accounts;
$verify->name = $request->name;
$verify->email = $request->email;
$verify->password = bcrypt($request->password);
$verify->token = str_random(70);
$verify->save(); */
$user = new User;
$user->name = $request->name;
$user->email = $request->email;
$user->phone = $request->phone;
$user->password = bcrypt($request->password);
$user->role_id = "1";
$user->save();
return response()->json([
'message' => 'Successfully created user!'
], 201);
} else {
return response()->json([
'message' => 'Puto el que la hackee'
], 201);
}
}
public function logout(Request $request)
{
$request->user()->token()->revoke();
return response()->json([
'message' => 'Successfully logged out'
]);
}
/**
* Get the authenticated User
*
* @return [json] user object
*/
public function user(Request $request)
{
return response()->json($request->user());
}
public function checkemail($token)
{
$verifyUser = Verify_accounts::where('token', $token)->first();
$user = new User;
$user->name = $verifyUser->name;
$user->email = $verifyUser->email;
$user->password = $verifyUser->password;
$user->role_id = "1";
$user->save();
Verify_accounts::destroy($verifyUser->id);
}
public function verify(Request $request)
{
$user = $request->user();
$user->phone = $request->phone;
$user->phone_verified_at = date("Y-m-d H:i:s");
$user->save();
return response()->json([
'message' => 'Successfully updated'
]);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function sendResetLinkResponse($response)
{
if (request()->header('Content-Type') == 'application/json') {
return response()->json(['success' => 'Email enviado con éxito.']);
}
return back()->with('status', 'Email enviado con éxito.');
}
protected function sendResetLinkFailedResponse($response)
{
if (request()->header('Content-Type') == 'application/json') {
return response()->json(['error' => 'Por favor contacte a soporte técnico.']);
}
return back()->withErrors(
['email' => 'Ha ocurrido un error']
);
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Auth;
use Socialite;
use Route;
use App\User;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}
public function handleProviderCallback($provider)
{
$user = Socialite::driver($provider)->user();
$authUser = $this->findUser($user, $provider);
Auth::login($authUser, true);
return redirect($this->redirectTo);
}
public function findUser($user, $provider) {
$authUser = User::where('social_id', $user->id . '_' . $provider)->first();
if($authUser) {
return $authUser;
}
return User::create([
'name' => $user->getName(),
'email' => $user->getEmail(),
'social_id' => $user->getId() . '_' . $provider,
]);
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Carbon\Carbon;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'phone' => ['required', 'string', 'min:8', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'phone' => $data['phone'],
'phone_verified_at' => Carbon::now(),
'role_id' => '2',
'password' => Hash::make($data['password']),
]);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View File

@@ -0,0 +1,162 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Banks;
use Illuminate\Support\Facades\Validator;
class BanksController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$banks = new Banks();
$banks = $banks->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('code', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('name', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('banks.index', compact('banks'));
} else {
return view('banks.ajax', compact('banks'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
//
if ($request->isMethod('get'))
return view('banks.form');
$rules = [
'code' => 'required|numeric',
'name' => 'required|string',
];
$messages = [
'code.required' => 'Se requiere un valor de código',
'name.required' => 'Se requiere el nombre del banco',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$bank = new Banks();
$bank->code = $request->code;
$bank->name = strip_tags($request->name);
$bank->save();
return redirect('banks');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('banks.form',['bank' => Banks::find($id)]);
$rules = [
'code' => 'required|numeric',
'name' => 'required|string',
];
$messages = [
'code.required' => 'Se requiere un valor de código',
'name.required' => 'Se requiere el nombre del banco',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$bank = Banks::find($id);
$bank->code = $request->code;
$bank->name = strip_tags($request->name);
$bank->save();
return redirect('banks');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Banks::destroy($id);
return redirect('banks');
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Categories;
use Illuminate\Support\Facades\Validator;
class CategoriesController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$categories = new Categories();
$categories = $categories->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('name', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('categories.index', compact('categories'));
} else {
return view('categories.ajax', compact('categories'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
//
if ($request->isMethod('get'))
return view('categories.form');
$rules = [
'name' => 'required|string',
'en_name' => 'required|string',
];
$messages = [
'name.required' => 'Se requiere el nombre de la categoría',
'en_name.required' => 'Se requiere el nombre de la categoría (en ingles)',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$category = new Categories();
$category->name = strip_tags($request->name);
$category->en_name = strip_tags($request->en_name);
$category->save();
return redirect('categories');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('categories.form',['category' => Categories::find($id)]);
$rules = [
'name' => 'required|string',
'en_name' => 'required|string',
];
$messages = [
'name.required' => 'Se requiere el nombre de la categoría',
'en_name.required' => 'Se requiere el nombre de la categoría (en ingles)',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$category = Categories::find($id);
$category->name = strip_tags($request->name);
$category->en_name = strip_tags($request->en_name);
$category->save();
return redirect('categories');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Categories::destroy($id);
return redirect('categories');
}
}

View File

@@ -0,0 +1,994 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Carbon\Carbon;
use OneSignal;
use Openpay;
use Exception;
use OpenpayApiError;
use OpenpayApiAuthError;
use OpenpayApiRequestError;
use OpenpayApiConnectionError;
use OpenpayApiTransactionError;
use App\iChambaParameter;
use App\Models\Suppliers;
use App\Models\Categories;
use App\Models\Cards;
use App\Models\Postulations;
use App\Models\CurrentContracts;
use App\Models\FinishedContracts;
use App\Models\Status;
use App\Models\Payments;
use App\Models\Coupon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Grimzy\LaravelMysqlSpatial\Types\Point;
class ContractController extends Controller
{
//
public function currentcontracts(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$currentcontracts = new CurrentContracts();
$currentcontracts = $currentcontracts->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('currentcontracts.index', compact('currentcontracts'));
} else {
return view('currentcontracts.ajax', compact('currentcontracts'));
}
}
public function mapcurrentcontracts(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$currentcontracts = new CurrentContracts();
$currentcontracts = $currentcontracts->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
return view('currentcontracts.map', compact('currentcontracts'));
}
public function finishedcontracts(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$finishedcontracts = new FinishedContracts();
$finishedcontracts = $finishedcontracts->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('finishedcontracts.index', compact('finishedcontracts'));
} else {
return view('finishedcontracts.ajax', compact('finishedcontracts'));
}
}
public function mapfinishedcontracts(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$finishedcontracts = new FinishedContracts();
$finishedcontracts = $finishedcontracts->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
return view('finishedcontracts.map', compact('finishedcontracts'));
}
public function create(Request $request) {
$rules = [
'postulation_id' => 'required|numeric',
'supplier_id' => 'required|numeric',
'card_id' => 'required|numeric',
'code' => 'required|numeric',
'device_id' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
'coupon' => 'nullable|string|regex:/(^[A-Za-z0-9 ]+$)+/',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$postulation = Postulations::where('id', $request->postulation_id)->first();
$coupon = Coupon::where('name', $request->coupon)->first();
Openpay::setProductionMode(true);
if ($user->id == $postulation->user_id) {
if ($request->card_id) {
$card = Cards::where('id', $request->card_id)->first();
}
$supplier = Suppliers::where('id', $request->supplier_id)->first();
$IVA = iChambaParameter::where('id', $supplier->IVA_id)->first();
$ISR = iChambaParameter::where('id', $supplier->ISR_id)->first();
$ichambafee = iChambaParameter::where('parameter', 'ichamba_fee')->first();
$category = Categories::where('id', $postulation->category_id)->first();
if ($card->user_id == $user->id) {
$contract = new CurrentContracts();
$contract->user_id = $postulation->user_id;
$contract->supplier_id = $supplier->id;
$contract->category_id = $postulation->category_id;
$contract->address = $postulation->address;
$contract->location = $postulation->location;
if (isset($postulation->int_number)) {
$contract->int_number = $postulation->int_number;
} else {
$contract->int_number = 0;
}
$contract->references = $postulation->references;
$contract->appointment = $postulation->appointment;
$contract->amount = ($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee);
if (isset($IVA->num_value) && isset($IVA->num_value)) {
$contract->IVA = $IVA->num_value;
$contract->ISR = $ISR->num_value;
$contract->revenue = ((($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee) * ((100 - $ichambafee->num_value) / 100)) * ((100 - $IVA->num_value - $ISR->num_value) / 100));
} else {
$contract->IVA = 0;
$contract->ISR = 0;
$contract->revenue = (($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee) * ((100 - $ichambafee->num_value) / 100));
}
$contract->ichamba_fee = $ichambafee->num_value;
$contract->details = $postulation->details;
$contract->en = $postulation->en;
if ($coupon) {
$checkccontracts = CurrentContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
$checkfcontracts = FinishedContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
if ($coupon->limit > 0) {
if(!isset($checkccontracts) && !isset($checkccontracts)) {
$fee = ($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee);
$discount = (($fee*(($coupon->percentage = null ? 0 : $coupon->percentage)/100))+($coupon->amount = null ? 0 : $coupon->amount));
$contract->coupon_id = $coupon->id;
$chargeData = array(
'source_id' => $card->token,
'method' => 'card',
'amount' => ((($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee)*(1 - (($coupon->percentage = null ? 0 : $coupon->percentage)/100)))-($coupon->amount = null ? 0 : $coupon->amount)),
'description' => ('Contrato del usuario: ' . $user->name . ' del servicio ' . $category->name . ' realizado por el proveedor: ' . $supplier->company_name),
'device_session_id' => $request->device_id,
'cvv2' => $request->code
);
}
}
} else {
$fee = ($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee);
$discount = 0;
$contract->coupon_id = null;
$chargeData = array(
'source_id' => $card->token,
'method' => 'card',
'amount' => ($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee),
'description' => ('Contrato del usuario: ' . $user->name . ' del servicio ' . $category->name . ' realizado por el proveedor: ' . $supplier->company_name),
'device_session_id' => $request->device_id,
'cvv2' => $request->code
);
}
if (!empty($request->card_id) && !empty($request->device_id) && !empty($request->code) && $fee > $discount) {
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customer = $openpay->customers->get($user->openpay_id);
$charge = $customer->charges->create($chargeData);
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay:' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
$contract->transaction_id = $charge->id;
} else if ($coupon) {
if ($coupon->limit > 0 && $discount >= $fee) {
if(!isset($checkccontracts) && !isset($checkccontracts)) {
$coupon->limit = $coupon->limit - 1;
$coupon->save();
$contract->transaction_id = $coupon->name;
}
}
}
$contract->status_id = 1;
$contract->code = mt_rand(100000, 999999);
$contract->save();
$delay_UTC = Carbon::parse($contract->appointment)->subMinutes(30)->toString();
Postulations::destroy($request->postulation_id);
OneSignal::sendNotificationUsingTags(
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Proveedor: has sido contratado"
);
//Schedule a notification for the supplier about its appointment
OneSignal::sendNotificationUsingTags(
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dírigeta a la sección de postulaciones contratados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = $delay_UTC,
$headings = "Proveedor, no olvides tu cita de hoy"
);
//Schedule a notification for the user about its appointment
OneSignal::sendNotificationUsingTags(
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dírigeta a la sección de contratos confirmados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $user->id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = $delay_UTC,
$headings = $user->name . ", no olvides tu cita de hoy"
);
return response()->json([
'message' => 'Servicio contratado exitosamente'
]);
}
}
}
}
public function coupon(Request $request) {
$rules = [
'postulation_id' => 'required|numeric',
'supplier_id' => 'required|numeric',
'coupon' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$postulation = Postulations::where('id', $request->postulation_id)->first();
$coupon = Coupon::where('name', $request->coupon)->first();
if($coupon) {
if ($user->id == $postulation->user_id) {
$supplier = Suppliers::where('id', $request->supplier_id)->first();
$IVA = iChambaParameter::where('id', $supplier->IVA_id)->first();
$ISR = iChambaParameter::where('id', $supplier->ISR_id)->first();
$ichambafee = iChambaParameter::where('parameter', 'ichamba_fee')->first();
$category = Categories::where('id', $postulation->category_id)->first();
$checkccontracts = CurrentContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
$checkfcontracts = FinishedContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
if (!isset($checkccontracts) && !isset($checkccontracts)) {
if($coupon->percentage == 100) {
if($coupon->limit > 0) {
$contract = new CurrentContracts();
$contract->user_id = $postulation->user_id;
$contract->supplier_id = $supplier->id;
$contract->category_id = $postulation->category_id;
$contract->address = $postulation->address;
$contract->location = $postulation->location;
if (isset($postulation->int_number)) {
$contract->int_number = $postulation->int_number;
} else {
$contract->int_number = 0;
}
$contract->references = $postulation->references;
$contract->appointment = $postulation->appointment;
$contract->amount = ($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee);
if (isset($IVA->num_value) && isset($IVA->num_value)) {
$contract->IVA = $IVA->num_value;
$contract->ISR = $ISR->num_value;
$contract->revenue = ((($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee) * ((100 - $ichambafee->num_value) / 100)) * ((100 - $IVA->num_value - $ISR->num_value) / 100));
} else {
$contract->IVA = 0;
$contract->ISR = 0;
$contract->revenue = (($supplier->minimun_fee < 150 ? 150 : $supplier->minimun_fee) * ((100 - $ichambafee->num_value) / 100));
}
$contract->ichamba_fee = $ichambafee->num_value;
$contract->details = $postulation->details;
$contract->en = $postulation->en;
$contract->coupon_id = $coupon->id;
$contract->transaction_id = $coupon->name;
$contract->status_id = 1;
$contract->code = mt_rand(100000, 999999);
$contract->save();
$delay_UTC = Carbon::parse($contract->appointment)->subMinutes(30)->toString();
Postulations::destroy($request->postulation_id);
OneSignal::sendNotificationUsingTags(
"Dirígete a la sección de postulaciones contratadas en la app para ver más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Proveedor: has sido contratado"
);
//Schedule a notification for the supplier about its appointment
OneSignal::sendNotificationUsingTags(
"Tienes un servicio en " . $contract->address . " hoy en 30 minutos. Dírigeta a la sección de postulaciones contratados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = $delay_UTC,
$headings = "Proveedor, no olvides tu cita de hoy"
);
//Schedule a notification for the user about its appointment
OneSignal::sendNotificationUsingTags(
"Tienes un servicio agendado hoy en " . $contract->address . " en 30 minutos. Dírigeta a la sección de contratos confirmados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $user->id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = $delay_UTC,
$headings = $user->name . ", no olvides tu cita de hoy"
);
$coupon->limit = $coupon->limit - 1;
$coupon->save();
return response()->json([
'name' => 'success'
]);
//
} else {
return response()->json([
'name' => 'expired'
]);
}
} else {
return response()->json($coupon);
}
} else {
return response()->json([
'name' => 'used'
]);
}
}
}
}
}
public function couponextra(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
'amount' => 'required|numeric',
'coupon' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$fcontract = FinishedContracts::where('id', $request->contract_id)->first();
$supplier = Suppliers::where('id', $fcontract->supplier_id)->first();
$IVA = iChambaParameter::where('id', $supplier->IVA_id)->first();
$ISR = iChambaParameter::where('id', $supplier->ISR_id)->first();
$ichambafee = iChambaParameter::where('parameter', 'ichamba_fee')->first();
$coupon = Coupon::where('name', $request->coupon)->first();
if($coupon) {
if ($user->id == $fcontract->user_id) {
$checkccontracts = CurrentContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
$checkfcontracts = FinishedContracts::where('coupon_id', $coupon->id)->where('user_id', $user->id)->first();
if (!isset($checkccontracts) && !isset($checkccontracts)) {
if($coupon->percentage == 100) {
if($coupon->limit > 0) {
$extra = new FinishedContracts();
$extra->user_id = $fcontract->user_id;
$extra->supplier_id = $fcontract->supplier_id;
$extra->category_id = $fcontract->category_id;
$extra->address = $fcontract->address;
$extra->location = $fcontract->location;
$extra->int_number = $fcontract->int_number;
$extra->references = $fcontract->references;
$extra->appointment = Carbon::now();
$extra->amount = ($request->amount < 150 ? 150 : $request->amount);
if (isset($IVA->num_value) && isset($IVA->num_value)) {
$extra->IVA = $IVA->num_value;
$extra->ISR = $ISR->num_value;
$extra->revenue = ((($request->amount < 150 ? 150 : $request->amount) * ((100 - $ichambafee->num_value) / 100)) * ((100 - $IVA->num_value - $ISR->num_value) / 100));
} else {
$extra->IVA = 0;
$extra->ISR = 0;
$extra->revenue = (($request->amount < 150 ? 150 : $request->amount) * ((100 - $ichambafee->num_value) / 100));
}
$extra->ichamba_fee = $ichambafee->num_value;
$extra->en = $fcontract->en;
$extra->coupon_id = $coupon->id;
$extra->transaction_id = $coupon->name;
$extra->status_id = 3;
$extra->parent_contract_id = $fcontract->id;
$extra->save();
$coupon->limit = $coupon->limit - 1;
$coupon->save();
return response()->json([
'name' => 'success'
]);
} else {
return response()->json([
'name' => 'expired'
]);
}
} else {
return response()->json($coupon);
}
} else {
return response()->json([
'name' => 'used'
]);
}
}
}
}
}
public function getcurrentcontracts(Request $request) {
$user = Auth::user();
$ccontracts = CurrentContracts::where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
$currentcontracts = array();
foreach($ccontracts as $ccontract) {
$category = Categories::where('id', $ccontract->category_id)->first();
$supplier = Suppliers::where('id', $ccontract->supplier_id)->first();
$time_limit = Carbon::parse($ccontract->appointment);
$day_limit = Carbon::parse($ccontract->created_at);
$currentcontractinfo = array(
'id' => $ccontract->id,
'phone' => $supplier->user->phone,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $ccontract->address,
'date' => $ccontract->appointment,
'supplier' => $supplier->company_name,
'status' => $ccontract->status_id,
'amount' => $ccontract->amount,
'code' => $ccontract->code,
'rescheadulable' => $day_limit->diffInDays($time_limit),
'time_limit' => $time_limit->diffInMinutes(Carbon::now()),
'past_due' => $time_limit->diffInHours(Carbon::now(), false)
);
$currentcontracts[] = $currentcontractinfo;
}
return response()->json($currentcontracts);
}
public function cancelcontract(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$ccontract = CurrentContracts::where('id', $request->contract_id)->first();
$supplier = Suppliers::where('id', $ccontract->supplier_id)->first();
if ($user->id == $ccontract->user_id) {
$time_limit = Carbon::parse($ccontract->appointment);
if ($time_limit->diffInHours(Carbon::now()) >= 24) {
if($ccontract->transaction_id != 'NO APPLY') {
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$refundData = array(
'description' => 'Reembolso del contrato con id: ' . $ccontract->id . ', del usuario ' . $user->name . '. Con proveedor: ' . $supplier->id,
);
$customer = $openpay->customers->get($user->openpay_id);
$charge = $customer->charges->get($ccontract->transaction_id);
$charge->refund($refundData);
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay:' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
}
}
$fcontract = new FinishedContracts();
$fcontract->user_id = $ccontract->user_id;
$fcontract->supplier_id = $ccontract->supplier_id;
$fcontract->category_id = $ccontract->category_id;
$fcontract->address = $ccontract->address;
$fcontract->location = $ccontract->location;
$fcontract->int_number = $ccontract->int_number;
$fcontract->references = $ccontract->references;
$fcontract->appointment = $ccontract->appointment;
$fcontract->amount = $ccontract->amount;
$fcontract->IVA = $ccontract->IVA;
$fcontract->ISR = $ccontract->ISR;
$fcontract->ichamba_fee = $ccontract->ichamba_fee;
$fcontract->revenue = $ccontract->revenue;
$fcontract->details = $ccontract->details;
$fcontract->en = $ccontract->en;
$fcontract->transaction_id = (!empty($charge->id) ? $charge->id : $ccontract->transaction_id);
$fcontract->status_id = 4;
$fcontract->save();
CurrentContracts::destroy($request->contract_id);
OneSignal::sendNotificationUsingTags(
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . "ha sido cancelado. Dírigeta a la sección de servicios contratados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Proveedor: un servicio ha sido cancelado"
);
return response()->json([
'message' => 'Servicio cancelado exitosamente'
]);
}
}
}
public function startcontract(Request $request) {
$rules = [
'contract_pin' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$supplier = $user->suppliers;
$ccontract = CurrentContracts::where('code', $request->contract_pin)->where('supplier_id', $supplier->id)->first();
if($ccontract) {
$time_limit = Carbon::parse($ccontract->appointment);
if ($time_limit->diffInMinutes(Carbon::now()) <= 120) {
$fcontract = new FinishedContracts();
$fcontract->user_id = $ccontract->user_id;
$fcontract->supplier_id = $ccontract->supplier_id;
$fcontract->category_id = $ccontract->category_id;
$fcontract->address = $ccontract->address;
$fcontract->location = $ccontract->location;
$fcontract->int_number = $ccontract->int_number;
$fcontract->references = $ccontract->references;
$fcontract->appointment = $ccontract->appointment;
$fcontract->amount = $ccontract->amount;
$fcontract->IVA = $ccontract->IVA;
$fcontract->ISR = $ccontract->ISR;
$fcontract->ichamba_fee = $ccontract->ichamba_fee;
$fcontract->revenue = $ccontract->revenue;
$fcontract->details = $ccontract->details;
$fcontract->en = $ccontract->en;
$fcontract->coupon_id = $ccontract->coupon_id;
$fcontract->transaction_id = $ccontract->transaction_id;
$fcontract->status_id = 3;
$fcontract->score = 5;
$fcontract->save();
$supplier->total_score = ($supplier->total_score + 5);
$supplier->finished_jobs = ($supplier->finished_jobs + 1);
$supplier->save();
CurrentContracts::destroy($ccontract->id);
$payment = new Payments();
$payment->contract_id = $fcontract->id;
$payment->supplier_id = $fcontract->supplier_id;
$payment->amount = $fcontract->amount;
$payment->status_id = null;
$payment->save();
OneSignal::sendNotificationUsingTags(
"El servicio en " . $fcontract->address . " el día " . substr($fcontract->appointment, 0, 10) . " ha sido iniciado. Dírigeta a la sección de servicios contratados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $fcontract->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Usuario: el proveedor ha iniciado el servicio"
);
return response()->json([
'message' => 'Servicio iniciado exitosamente'
]);
} else {
return response()->json([
'message' => 'No service'
]);
}
} else {
return response()->json([
'message' => 'No service'
]);
}
}
}
public function extra(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
'amount' => 'required|numeric',
'card_id' => 'required|numeric',
'code' => 'required|numeric',
'device_id' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
'coupon' => 'nullable|string|regex:/(^[A-Za-z0-9 ]+$)+/',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$coupon = Coupon::where('name', $request->coupon)->first();
$fcontract = FinishedContracts::where('id', $request->contract_id)->first();
Openpay::setProductionMode(true);
if ($user->id == $fcontract->user_id) {
$card = Cards::where('id', $request->card_id)->first();
$IVA = iChambaParameter::where('id', $supplier->IVA_id)->first();
$ISR = iChambaParameter::where('id', $supplier->ISR_id)->first();
$ichambafee = iChambaParameter::where('parameter', 'ichamba_add_fee')->first();
$supplier = Suppliers::where('id', $fcontract->supplier_id)->first();
if ($card->user_id == $user->id) {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
}
$extra = new FinishedContracts();
$extra->user_id = $fcontract->user_id;
$extra->supplier_id = $fcontract->supplier_id;
$extra->category_id = $fcontract->category_id;
$extra->address = $fcontract->address;
$extra->location = $fcontract->location;
$extra->int_number = $fcontract->int_number;
$extra->references = $fcontract->references;
$extra->appointment = Carbon::now();
$extra->amount = ($request->amount < 150 ? 150 : $request->amount);
if (isset($IVA->num_value) && isset($IVA->num_value)) {
$extra->IVA = $IVA->num_value;
$extra->ISR = $ISR->num_value;
$extra->revenue = ((($request->amount < 150 ? 150 : $request->amount) * ((100 - $ichambafee->num_value) / 100)) * ((100 - $IVA->num_value - $ISR->num_value) / 100));
} else {
$extra->IVA = 0;
$extra->ISR = 0;
$extra->revenue = (($request->amount < 150 ? 150 : $request->amount) * ((100 - $ichambafee->num_value) / 100));
}
$extra->ichamba_fee = $ichambafee->num_value;
$extra->en = $fcontract->en;
if ($coupon) {
if ($coupon->limit > 0) {
$extra->coupon_id = $coupon->id;
$chargeData = array(
'source_id' => $card->token,
'method' => 'card',
'amount' => ((($request->amount < 150 ? 150 : $request->amount)*(1 - (($coupon->percentage = null ? 0 : $coupon->percentage)/100)))-($coupon->amount = null ? 0 : $coupon->amount)),
'description' => ('Contrato del usuario: ' . $user->name . ' del servicio ' . $category->name . ' realizado por el proveedor: ' . $supplier->company_name),
'device_session_id' => $request->device_id,
'cvv2' => $request->code
);
} else {
$extra->coupon_id = null;
$chargeData = array(
'source_id' => $card->token,
'method' => 'card',
'amount' => ($request->amount < 150 ? 150 : $request->amount),
'description' => ('Contrato del usuario: ' . $user->name . ' del servicio ' . $category->name . ' realizado por el proveedor: ' . $supplier->company_name),
'device_session_id' => $request->device_id,
'cvv2' => $request->code
);
}
} else {
$extra->coupon_id = null;
$chargeData = array(
'source_id' => $card->token,
'method' => 'card',
'amount' => ($request->amount < 150 ? 150 : $request->amount),
'description' => ('Contrato del usuario: ' . $user->name . ' del servicio ' . $category->name . ' realizado por el proveedor: ' . $supplier->company_name),
'device_session_id' => $request->device_id,
'cvv2' => $request->code
);
}
$customer = $openpay->customers->get($user->openpay_id);
$charge = $customer->charges->create($chargeData);
$extra->transaction_id = $charge->id;
$extra->status_id = 3;
$extra->parent_contract_id = $fcontract->id;
$extra->save();
if ($coupon) {
$coupon->limit = $coupon->limit - 1;
$coupon->save();
}
return response()->json([
'message' => 'extra_added'
]);
}
}
}
public function getfinishedcontracts(Request $request) {
$user = Auth::user();
$fcontracts = FinishedContracts::where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
$finishedcontracts = array();
foreach($fcontracts as $fcontract) {
$category = Categories::where('id', $fcontract->category_id)->first();
$supplier = Suppliers::where('id', $fcontract->supplier_id)->first();
$time_limit = Carbon::parse($fcontract->appointment);
$day_limit = Carbon::parse($fcontract->created_at);
$finishedcontractinfo = array(
'id' => $fcontract->id,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $fcontract->address,
'date' => $fcontract->appointment,
'date_difference' => $time_limit->diff(Carbon::now(), false)->days,
'supplier' => $supplier->company_name,
'amount' => $fcontract->amount,
'scored' => $fcontract->scored_at,
'parent' => $fcontract->parent_contract_id,
'status' => $fcontract->status->name
);
$finishedcontracts[] = $finishedcontractinfo;
}
return response()->json($finishedcontracts);
}
public function reviewcontract(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
'rate' => 'required|numeric',
'comment' => 'string',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$fcontract = FinishedContracts::where('id', $request->contract_id)->first();
if ($fcontract->user_id == $user->id) {
$fcontract->score = $fcontract->score - (5 - $request->rate);
$fcontract->scored_at = Carbon::now();
$fcontract->comments = strip_tags($request->comment);
$fcontract->save();
$supplier = Suppliers::where('id', $fcontract->supplier_id)->first();
$supplier->total_score = $supplier->total_score - (5 - $request->rate);
$supplier->save();
}
}
return response()->json([
'message' => 'Calificación registrada con éxito, muchas gracias'
]);
}
public function deletemissed()
{
$contracts = CurrentContracts::whereDate('appointment', '<', Carbon::now())->delete();
}
public function currentdestroy($id)
{
CurrentContracts::destroy($id);
return redirect('currentcontracts');
}
public function finisheddestroy($id)
{
FinishedContracts::destroy($id);
return redirect('finishedcontracts');
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@@ -0,0 +1,170 @@
<?php
namespace App\Http\Controllers;
use App\Models\Coupon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class CouponController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$coupons = new Coupon();
$coupons = $coupons->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('name', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('percentage', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('limit', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('coupons.index', compact('coupons'));
} else {
return view('coupons.ajax', compact('coupons'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
//
if ($request->isMethod('get'))
return view('coupons.form');
$rules = [
'name' => 'required|string',
'percentage' => 'nullable|numeric',
'amount' => 'nullable|numeric',
'limit' => 'nullable|numeric',
];
$messages = [
'name.required' => 'Se requiere un nombre de cupon',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$coupon = new Coupon();
$coupon->name = strip_tags($request->name);
$coupon->percentage = $request->percentage;
$coupon->amount = $request->amount;
$coupon->limit = $request->limit;
$coupon->save();
return redirect('coupons');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Models\Coupon $coupon
* @return \Illuminate\Http\Response
*/
public function show(Coupon $coupon)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Coupon $coupon
* @return \Illuminate\Http\Response
*/
public function edit(Coupon $coupon)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Coupon $coupon
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('coupons.form', ['coupon' => Coupon::find($id)]);
$rules = [
'name' => 'required|string',
'percentage' => 'nullable|numeric',
'amount' => 'nullable|numeric',
'limit' => 'nullable|numeric',
];
$messages = [
'name.required' => 'Se requiere un nombre de cupon',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$coupon = Coupon::find($id);
$coupon->name = strip_tags($request->name);
$coupon->percentage = $request->percentage;
$coupon->amount = $request->amount;
$coupon->limit = $request->limit;
$coupon->save();
return redirect('coupons');
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Coupon $coupon
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
Coupon::destroy($id);
return redirect('coupons');
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}

View File

@@ -0,0 +1,179 @@
<?php
namespace App\Http\Controllers;
use App\iChambaParameter;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class IChambaParameterController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$ichambaparameters = new iChambaParameter();
$ichambaparameters = $ichambaparameters->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('parameter', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('num_value', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('string_value', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('parameters.index', compact('ichambaparameters'));
} else {
return view('parameters.ajax', compact('ichambaparameters'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
//
if ($request->isMethod('get'))
return view('parameters.form');
$rules = [
'parameter' => 'required|string',
'num_value' => 'nullable|numeric',
'string_value' => 'nullable|string',
];
$messages = [
'parameter.required' => 'Se requiere un nombre de parametro',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$ichambaparameter = new iChambaParameter();
$ichambaparameter->parameter = strip_tags($request->parameter);
$ichambaparameter->num_value = $request->num_value;
$ichambaparameter->string_value = strip_tags($request->string_value);
$ichambaparameter->save();
return redirect('parameters');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\iChambaParameter $iChambaParameter
* @return \Illuminate\Http\Response
*/
public function show(iChambaParameter $iChambaParameter)
{
//
}
public function parameters()
{
//
$ichambaparameters = new iChambaParameter();
$min_time = $ichambaparameters->where('parameter', 'min_time')->first()->num_value;
$max_time = $ichambaparameters->where('parameter', 'max_time')->first()->num_value;
return response()->json([
'min_time' => $min_time,
'max_time' => $max_time
]);
}
/**
* Show the form for editing the specified resource.
*
* @param \App\iChambaParameter $iChambaParameter
* @return \Illuminate\Http\Response
*/
public function edit(iChambaParameter $iChambaParameter)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\iChambaParameter $iChambaParameter
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('parameters.form', ['ichambaparameter' => iChambaParameter::find($id)]);
$rules = [
'parameter' => 'required|string',
'num_value' => 'nullable|numeric',
'string_value' => 'nullable|string',
];
$messages = [
'parameter.required' => 'Se requiere un nombre de parametro',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$ichambaparameter = iChambaParameter::find($id);
$ichambaparameter->parameter = strip_tags($request->parameter);
$ichambaparameter->num_value = $request->num_value;
$ichambaparameter->string_value = strip_tags($request->string_value);
$ichambaparameter->save();
return redirect('parameters');
}
/**
* Remove the specified resource from storage.
*
* @param \App\iChambaParameter $iChambaParameter
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
iChambaParameter::destroy($id);
return redirect('parameters');
}
}

View File

@@ -0,0 +1,254 @@
<?php
namespace App\Http\Controllers;
use App\NoHome;
use App\User;
use Carbon\Carbon;
use OneSignal;
use Image;
use Storage;
use App\Models\CurrentContracts;
use App\Models\FinishedContracts;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Grimzy\LaravelMysqlSpatial\Types\Point;
use Illuminate\Support\Facades\File;
class NoHomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\NoHome $noHome
* @return \Illuminate\Http\Response
*/
public function show(NoHome $noHome)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\NoHome $noHome
* @return \Illuminate\Http\Response
*/
public function edit(NoHome $noHome)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\NoHome $noHome
* @return \Illuminate\Http\Response
*/
public function update(Request $request, NoHome $noHome)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\NoHome $noHome
* @return \Illuminate\Http\Response
*/
public function destroy(NoHome $noHome)
{
//
}
public function test(Request $request)
{
$rules = [
'contract_id' => 'required|numeric',
'description' => 'required|string',
'lat' => 'numeric|nullable',
'lng' => 'numeric|nullable',
//'house_photo' => 'image|mimes:jpeg,jpg,png|max:2048',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return response()->json([
'message' => 'Por favor corrija'
]);
} else {
$user = Auth::user();
$disk = Storage::disk('gcs');
if ($request->file('house_photo')) {
$name = Carbon::now();
$filename = $name . '.jpg';
$disk->putFileAs('img/users/'. $user->id . '/', $request->file('house_photo'), $filename, 'public');
}
return response()->json([
//'message' => 'Por favor espere a los 10 minutos de tolerancia de la hora acordada'
'contract_id' => $request->contract_id,
'lat' => $request->lat,
'lng' => $request->lng,
]);
}
}
public function nohomecheck(Request $request){
$user = Auth::user();
$contract = CurrentContracts::where('supplier_id', $user->suppliers->id)->whereBetween('appointment', [Carbon::now()->subMinutes(15), Carbon::now()->addMinutes(10)])->first();
if ($contract) {
$client = User::where('id', $contract->user_id)->first();
if (Carbon::now()->diffInMinutes($contract->appointment, false) < 10) {
return response()->json($contract);
} else {
OneSignal::sendNotificationUsingTags(
"El proveedor para el servicio en " . $contract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $client->id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = $client->name + ", tu proveedor del servicio ha llegado"
);
return response()->json([
//'message' => 'Por favor espere a los 10 minutos de tolerancia de la hora acordada'
'message' => 'wait'
]);
}
} else {
return response()->json([
//'message' => 'No hay contratos citados a esta hora'
'message' => 'no-contract'
]);
}
}
public function nohomeconfirm(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
'description' => 'required|string',
'lat' => 'numeric|nullable',
'lng' => 'numeric|nullable',
//'house_photo' => 'image|mimes:jpeg,jpg,png|max:2048',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$disk = Storage::disk('gcs');
$ccontract = CurrentContracts::where('id', $request->contract_id)->first();
$client = User::where('id', $ccontract->user_id)->first();
if ($user->suppliers->id == $ccontract->supplier_id) {
if (Carbon::now()->diffInMinutes($ccontract->appointment, false) >= 11) {
if ($request->lat != null && $request->lng != null) {
$geometry = new Point($request->lat, $request->lng);
}
$fcontract = new FinishedContracts();
$fcontract->user_id = $ccontract->user_id;
$fcontract->supplier_id = $ccontract->supplier_id;
$fcontract->category_id = $ccontract->category_id;
$fcontract->address = $ccontract->address;
$fcontract->location = $ccontract->location;
$fcontract->int_number = $ccontract->int_number;
$fcontract->references = $ccontract->references;
$fcontract->appointment = $ccontract->appointment;
$fcontract->amount = $ccontract->amount;
$fcontract->details = $ccontract->details;
$fcontract->IVA = $ccontract->IVA;
$fcontract->ISR = $ccontract->ISR;
$fcontract->ichamba_fee = $ccontract->ichamba_fee;
$fcontract->revenue = $ccontract->revenue;
$fcontract->details = $ccontract->details;
$fcontract->en = $ccontract->en;
$fcontract->transaction_id = $ccontract->transaction_id;
$fcontract->status_id = 5;
$fcontract->save();
$nohome = new NoHome();
$nohome->contract_id = $fcontract->id;
if ($geometry != null) {
$nohome->location = $geometry;
}
if ($request->file('house_photo')) {
$disk = Storage::disk('gcs');
$name = Carbon::now();
$filename = $name . '.jpg';
$disk->putFileAs('img/users/'. $user->id . '/', $request->file('house_photo'), $filename, 'public');
$nohome->house_photo = $disk->url('img/users/'. $user->id . '/' . $filename);
}
$nohome->house_description = $request->description;
$nohome->save();
return response()->json([
'message' => 'Ausencia registrada con éxito, nos comunicaremos con usted por correo electrónico en caso de alguna circunstancia'
]);
} else {
OneSignal::sendNotificationUsingTags(
"El proveedor para el servicio en " . $ccontract->address . " ha llegado. Dírigeta a la sección de contratos confirmados para más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $client->id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = $client->name . ", tu proveedor del servicio ha llegado"
);
return response()->json([
'order' => 'wait',
'message' => 'Por favor espere a los 10 minutos de tolerancia de la hora acordada'
]);
}
}
}
}
}

View File

@@ -0,0 +1,381 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Carbon\Carbon;
use App\User;
use App\Models\Suppliers;
use App\Models\Payments;
use App\Models\FinishedContracts;
use App\Models\Cards;
use Openpay;
use Exception;
use OpenpayApiError;
use OpenpayApiAuthError;
use OpenpayApiRequestError;
use OpenpayApiConnectionError;
use OpenpayApiTransactionError;
require_once '../vendor/autoload.php';
class PaymentController extends Controller
{
//
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$payments = new FinishedContracts();
$payments = $payments->where('status_id', 3)->where('paid', false)->where('transaction_id', '!=', 'NO APPLY')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('payments.index', compact('payments'));
} else {
return view('payments.ajax', compact('payments'));
}
}
public function cardsindex(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$cards= new Cards();
$cards = $cards->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('token', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('cards.index', compact('cards'));
} else {
return view('cards.ajax', compact('cards'));
}
}
public function destroy($id)
{
$credit_card = Cards::where('id', $id)->first();
$user = User::where('id', $credit_card->user_id)->first();
Openpay::setProductionMode(true);
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customer = $openpay->customers->get($user->openpay_id);
$card = $customer->cards->get($credit_card->token);
$card->delete();
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error en la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error en los datos requeridos'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
Cards::destroy($id);
return redirect('cards');
}
public function addcard(Request $request)
{
$rules = [
'token' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
'device_id' => 'required|string|regex:/(^[A-Za-z0-9 ]+$)+/',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$user = $request->user();
Openpay::setProductionMode(true);
if ($user->openpay_id == null) {
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customerData = array(
'external_id' => $user->id,
'name' => $user->name,
'email' => $user->email,
);
$customer = $openpay->customers->add($customerData);
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
$user->openpay_id = $customer->id;
$user->save();
}
$cardDataRequest = array(
'token_id' => $request->token,
'device_session_id' => $request->device_id
);
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customer = $openpay->customers->get($user->openpay_id);
$card = $customer->cards->add($cardDataRequest);
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
$card = new Cards();
$card->user_id = $user->id;
$card->token = $request->token;
$card->save();
return response()->json([
'message' => 'Tarjeta guardada exitosamente'
]);
}
public function deletecard(Request $request)
{
$rules = [
'card_id' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$user = $request->user();
$credit_card = Cards::where('id', $request->card_id)->first();
Openpay::setProductionMode(true);
if ($credit_card->user_id == $user->id) {
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customer = $openpay->customers->get($user->openpay_id);
$card = $customer->cards->get($credit_card->token);
$card->delete();
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
Cards::destroy($request->card_id);
return response()->json([
'message' => 'Tarjeta eliminada exitosamente'
]);
}
}
public function getcards(Request $request)
{
$user = $request->user();
Openpay::setProductionMode(true);
if ($user->openpay_id) {
try {
$openpay = Openpay::getInstance(config('app.openpay_id'), config('app.openpay_apikey'));
$customer = $openpay->customers->get($user->openpay_id);
} catch (OpenpayApiTransactionError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la transacción'
]);
} catch (OpenpayApiRequestError $e) {
return response()->json([
'type' => 'error',
'message' => 'No se pudo procesar la operación'
]);
} catch (OpenpayApiConnectionError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiAuthError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (OpenpayApiError $e) {
return response()->json([
'type' => 'error',
'message' => 'Error al conectarse a Openpay: ' . $e->getMessage()
]);
} catch (Exception $e) {
return response()->json([
'type' => 'error',
'message' => 'Error: ' . $e->getMessage()
]);
}
$cards = Cards::where('user_id', $user->id)->get();
$cardsinfo = array();
foreach ($cards as $credit_card) {
$card = $customer->cards->get($credit_card->token);
$cardinfo = array(
'id' => $credit_card->id,
'brand' => $card->brand,
'card_number' => $card->card_number,
);
$cardsinfo[] = $cardinfo;
}
return response()->json($cardsinfo);
}
}
}

View File

@@ -0,0 +1,370 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Carbon\Carbon;
use OneSignal;
use App\Models\Suppliers;
use App\Models\Categories;
use App\Models\Postulations;
use App\Models\FinishedContracts;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Grimzy\LaravelMysqlSpatial\Types\Point;
class PostulationController extends Controller
{
//
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$postulations = new Postulations();
$postulations = $postulations->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('postulations.index', compact('postulations'));
} else {
return view('postulations.ajax', compact('postulations'));
}
}
public function map(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$postulations = new Postulations();
$postulations = $postulations->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('user_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('address', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('amount', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
return view('postulations.map', compact('postulations'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request) {
$rules = [
'category' => 'required|string',
'address' => 'required|string',
'int_number' => 'numeric|nullable',
'references' => 'string|nullable',
'setdate' => 'required|string',
'sethour' => 'required|string',
'details' => 'string|nullable',
'lat' => 'required|numeric',
'lng' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return response()->json($validator->messages());
} else {
$user = Auth::user();
$geometry = new Point($request->lat, $request->lng);
$category = Categories::where('name', strip_tags($request->category))->orwhere('en_name', strip_tags($request->category))->first();
$distance = 0.5;
$suppliers = Suppliers::distance('location', $geometry, $distance)->get();
if ($suppliers != '[]') {
$postulation = new Postulations();
$postulation->user_id = $user->id;
$postulation->category_id = $category->id;
$postulation->address = strip_tags($request->address);
$postulation->location = $geometry;
$postulation->int_number = $request->int_number;
$postulation->references = preg_replace('/\d+/', '', strip_tags($request->references));
$timeoffset = str_replace("0", "", substr(substr(strip_tags($request->sethour), 23), 0, 3));
$postulation->appointment = Carbon::createFromFormat('Y-m-d H:i:s', (substr(strip_tags($request->setdate), 0, 10) . ' ' . substr(substr(strip_tags($request->sethour), 11), 0, 8)), $timeoffset)->tz('UTC');
$postulation->amount = 5000;
$postulation->details = preg_replace('/\d+/', '', strip_tags($request->details));
$postulation->save();
OneSignal::sendNotificationUsingTags(
"Coméntele al Ing. que hay una postulación",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => "128"]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Admin: hay nueva postulación"
);
foreach ($suppliers as $supplier) {
if (in_array($category->id, $supplier->categories->pluck('id')->toArray())) {
OneSignal::sendNotificationUsingTags(
"Dirígete a la sección de postulaciones en la app para ver más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $supplier->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Proveedor: hay nueva postulación"
);
}
}
$minutes = intval(substr(substr($request->setdate, 14), 0, 2) + 15);
$hours = intval(substr(substr($request->setdate, 11), 0, 2) + 1);
if ($minutes > 59) {
if ($hours > 23){
$delay_msg = Carbon::now()->addDays(1)->toDateString() . ' ' . ($hours - 24) . ':' . ($minutes - 60) . substr(substr($request->setdate, 16), 0, 3);
} else {
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . ($minutes - 60) . substr(substr($request->setdate, 16), 0, 3);
}
} else {
$delay_msg = substr($request->sethour, 0, 10) . ' ' . $hours . ':' . $minutes . substr(substr($request->setdate, 16), 0, 3);
}
$delay_UTC = Carbon::now()->addMinutes(15)->toString();
OneSignal::sendNotificationUsingTags(
"Dirígete a la sección de contratos en la app para ver más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $user->id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = $delay_UTC,
$headings = "Búsqueda Finalizada"
);
return response()->json([
'message' => 'Servicio solicitado, espere a que un proveedor se postule'
]);
} else {
return response()->json([
'message' => 'No Provider'
]);
}
}
}
public function postulate(Request $request) {
$rules = [
'postulation_id' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$postulation = Postulations::where('id', $request->postulation_id)->first();
$time_created = Carbon::parse($postulation->created_at);
$time_limit = (9900 - Carbon::now()->diffInMinutes($time_created));
$supplier = Suppliers::where('user_id', $user->id)->first();
if ($time_limit > 0) {
if (in_array($postulation->category_id, $supplier->categories->pluck('id')->toArray())) {
if($supplier->membership == 1) {
OneSignal::sendNotificationUsingTags(
"Dirígete a la sección de contratos en la app para ver más detalles",
array(
["field" => "tag", "key" => "iChamba_ID", "relation" => "=", "value" => $postulation->user_id]
),
$url = null,
$data = null,
$buttons = null,
$schedule = null,
$headings = "Un proveedor certificado se ha postulado"
);
}
$supplier->postulations()->attach($request->postulation_id);
$supplier->save();
return response()->json([
'message' => 'Se ha postulado al servicio exitosamente'
]);
}
} else {
return response()->json([
'message' => 'La postulación ha caducado'
]);
}
}
}
public function getpendingcontracts(Request $request) {
$user = Auth::user();
$postulations = Postulations::where('user_id', $user->id)->orderBy('created_at', 'DESC')->get();
$pendingcontracts = array();
foreach($postulations as $postulation) {
$time_limit = Carbon::parse($postulation->appointment);
if ($time_limit->diffInMinutes(Carbon::now(), false) <= -60) {
$category = Categories::where('id', $postulation->category_id)->first();
$pendingcontractinfo = array(
'id' => $postulation->id,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $postulation->address,
'date' => $postulation->appointment,
'amount' => $postulation->amount
);
$pendingcontracts[] = $pendingcontractinfo;
}
}
return response()->json($pendingcontracts);
}
public function getfinishedpostulations(Request $request) {
$user = Auth::user();
$postulations = FinishedContracts::where('supplier_id', $user->suppliers->id)->orderBy('created_at', 'DESC')->get();
$finishedpostulations = array();
foreach($postulations as $postulation) {
$time_limit = Carbon::parse($postulation->appointment);
$category = Categories::where('id', $postulation->category_id)->first();
$finishedpostulationinfo = array(
'id' => $postulation->id,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $postulation->address,
'date' => $postulation->appointment,
'amount' => $postulation->amount
);
$finishedpostulations[] = $finishedpostulationinfo;
}
return response()->json($finishedpostulations);
}
public function getpostulants(Request $request) {
$rules = [
'postulation_id' => 'required|numeric',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$postulation = Postulations::where('id', $request->postulation_id)->first();
if ($postulation->user_id == $user->id) {
$category = Categories::where('id', $postulation->category_id)->first();
$suppliers = Suppliers::whereHas('postulations', function($q) use ($request) {
$q->where('postulations_id', $request->postulation_id);
})->get();
$pcontractsuppliers = array();
if ($suppliers != '[]') {
foreach($suppliers as $supplier) {
$pcontractsupplier = array(
'id' => $postulation->id,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $postulation->address,
'date' => $postulation->appointment,
'amount' => $postulation->amount,
'supplier_id' => $supplier->id,
'supplier' => $supplier->company_name,
'tags' => $supplier->tags,
'cover_photo' => $supplier->cover_photo,
'membership' => $supplier->membership,
'fee' => $supplier->minimun_fee,
'score' => round($supplier->total_score/$supplier->finished_jobs, 1),
);
$pcontractsuppliers[] = $pcontractsupplier;
}
$pcontractsuppliercollection = collect($pcontractsuppliers)->sortByDesc('membership')->sortByDesc('score');
$pcontractsupplier = $pcontractsuppliercollection->values()->all();
} else {
$pcontractsupplier = array(
'id' => $postulation->id,
'category' => $category->name,
'en_category' => $category->en_name,
'address' => $postulation->address,
'date' => $postulation->appointment,
'amount' => $postulation->amount,
'supplier_id' => null,
'supplier' => null,
'tags' => null,
'cover_photo' => null,
'membership' => null,
'fee' => null,
'score' => null,
);
$pcontractsuppliers[] = $pcontractsupplier;
$pcontractsupplier = $pcontractsuppliers;
}
return response()->json($pcontractsupplier);
}
}
}
public function deleteexpired()
{
$postulations = Postulations::whereDate('appointment', '<', Carbon::now())->delete();
}
public function destroy($id)
{
Postulations::destroy($id);
return redirect('postulations');
}
}

View File

@@ -0,0 +1,112 @@
<?php
namespace App\Http\Controllers;
use App\ReportComment;
use App\Models\FinishedContracts;
use App\NoHome;
use Illuminate\Http\Request;
class ReportCommentController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request, $id, $contract_id)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$contract = FinishedContracts::where('id', $contract_id)->first();
$nohome = NoHome::where('contract_id', $contract_id)->first();
$comments = new ReportComment();
$comments = $comments->where('report_id', $id)
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->isMethod('get'))
return view('reports.comments', compact('comments', 'contract', 'nohome'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\ReportComment $reportComment
* @return \Illuminate\Http\Response
*/
public function show(ReportComment $reportComment)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\ReportComment $reportComment
* @return \Illuminate\Http\Response
*/
public function edit(ReportComment $reportComment)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\ReportComment $reportComment
* @return \Illuminate\Http\Response
*/
public function update(Request $request, ReportComment $reportComment)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\ReportComment $reportComment
* @return \Illuminate\Http\Response
*/
public function destroy($id, $contract_id)
{
//
ReportComment::destroy($id);
return redirect('reports/comments/'.$id.'/'.$contract_id);
}
}

View File

@@ -0,0 +1,183 @@
<?php
namespace App\Http\Controllers;
use App\User;
use App\Report;
use App\ReportComment;
use App\Models\FinishedContracts;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
class ReportController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$reports = new Report();
$reports = $reports->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('contract_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('moderator_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('veredict', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('reports.index', compact('reports'));
} else {
return view('reports.ajax', compact('reports'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Report $report
* @return \Illuminate\Http\Response
*/
public function show(Report $report)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Report $report
* @return \Illuminate\Http\Response
*/
public function veredict(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('reports.veredict', ['report' => Report::find($id)]);
$rules = [
'veredict' => 'required|string',
];
$messages = [
'veredict.required' => 'Se requiere un veredicto',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$report = Report::find($id);
$report->veredict = strip_tags($request->veredict);
$coupon->save();
return redirect('reports');
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Report $report
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Report $report)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Report $report
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
Report::destroy($id);
return redirect('reports');
}
public function report(Request $request) {
$rules = [
'contract_id' => 'required|numeric',
'comment' => 'required|string',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
} else {
$user = Auth::user();
$contract = FinishedContracts::where('id', $request->contract_id)->first();
if ($user->id == $contract->user_id) {
$report = new Report();
$report->contract_id = $contract->id;
$moderator = User::where('role_id', 5)->get();
if ($moderator != '[]') {
$report->moderator_id = $moderator->random()->id;
} else {
$report->moderator_id = User::where('role_id', 7)->first()->id;
}
$report->save();
$reportcomment = new ReportComment();
$reportcomment->report_id = $report->id;
$reportcomment->user_id = $user->id;
$reportcomment->comment = strip_tags($request->comment);
$reportcomment->save();
$contract->status_id = 6;
$contract->save();
return response()->json([
'message' => 'Reporte registrado con éxito, nos comunicaremos con usted por correo electrónico a la brevedad para continuar con el caso'
]);
}
}
}
}

View File

@@ -0,0 +1,151 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Status;
use Illuminate\Support\Facades\Validator;
class StatusController extends Controller
{
//
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$status = new Status();
$status = $status->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('name', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('status.index', compact('status'));
} else {
return view('status.ajax', compact('status'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create(Request $request)
{
//
if ($request->isMethod('get'))
return view('status.form');
$rules = [
'name' => 'required|string',
];
$messages = [
'name.required' => 'Se requiere el nombre del status',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$status = new Status();
$status->name = strip_tags($request->name);
$status->save();
return redirect('status');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('status.form',['status' => Status::find($id)]);
$rules = [
'name' => 'required|string',
];
$messages = [
'name.required' => 'Se requiere el nombre del status',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$status = Status::find($id);
$status->name = strip_tags($request->name);
$status->save();
return redirect('status');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
Status::destroy($id);
return redirect('status');
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\Validator;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
//
$request->session()->put('search', $request
->has('search') ? strip_tags($request->get('search')) : ($request->session()
->has('search') ? strip_tags($request->session()->get('search')) : ''));
$request->session()->put('field', $request
->has('field') ? strip_tags($request->get('field')) : ($request->session()
->has('field') ? strip_tags($request->session()->get('field')) : 'id'));
$request->session()->put('sort', $request
->has('sort') ? strip_tags($request->get('sort')) : ($request->session()
->has('sort') ? strip_tags($request->session()->get('sort')) : 'asc'));
//$headers = $request->get('header') != '' ? $request->get('header') : -1;
$users = new User();
$users = $users->where('id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('name', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('email', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('role_id', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orwhere('phone', 'LIKE', '%' . strip_tags($request->session()->get('search')) . '%')
->orderBy(strip_tags($request->session()->get('field')), strip_tags($request->session()->get('sort')))
->paginate(10);
if ($request->ajax()) {
return view('users.index', compact('users'));
} else {
return view('users.ajax', compact('users'));
}
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
if ($request->isMethod('get'))
return view('users.form',['user' => User::find($id)]);
$rules = [
'name' => 'required|string',
'email' => 'required|string|email',
'role' => 'required|numeric',
'openpay_id' => 'string|nullable',
];
$messages = [
'name.required' => 'Se requiere un nombre de usuario',
'email.required' => 'Se requiere un correo electrónico válido',
'role.required' => 'Se requiere un rol',
];
$validator = Validator::make($request->all(), $rules, $messages);
if ($validator->fails()) {
return redirect()->back()->withInput($request->all())->withErrors($validator);
}
$user = User::find($id);
$user->name = strip_tags($request->name);
$user->email = $request->email;
$user->role_id = $request->role;
if ($request->openpay_id == "null" OR $request->openpay_id == null){
$user->openpay_id = null;
}
$user->save();
return redirect('users');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
User::destroy($id);
return redirect('users');
}
}

84
app/Http/Kernel.php Normal file
View File

@@ -0,0 +1,84 @@
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\Cors::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'rolecheck' => \App\Http\Middleware\RoleCheck::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'superadmin' => \App\Http\Middleware\SuperAdmin::class,
'appenginecron' => \App\Http\Middleware\AppEngineCron::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
/**
* The priority-sorted list of middleware.
*
* This forces non-global middleware to always be in the given order.
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
class AppEngineCron
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->hasHeader('X-Appengine-Cron')) {
return response()->json(trans('auth.unauthorized'), 401);
}
return $next($request);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$allowedOrigins = ['http://localhost', 'ionic://localhost'];
if (in_array($request->server('HTTP_ORIGIN'), $allowedOrigins)) {
return $next($request)
->header('Access-Control-Allow-Origin', $request->server('HTTP_ORIGIN'))
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS')
->header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With, X-XSRF-TOKEN');
}
return $next($request);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
return $next($request);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
class RoleCheck
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
if($request->user()) {
if($request->user()->role_id == $role OR $request->user()->role_id >= 6) {
return $next($request);
}
} else {
return redirect('home');
}
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
class SuperAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if($request->user()->role_id == 7) {
return $next($request);
} else {
return redirect('home');
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//
];
}

22
app/Models/Banks.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use App\User;
use App\Models\Suppliers;
use Illuminate\Database\Eloquent\Model;
class Banks extends Model
{
protected $fillable = [
'code',
'name',
];
public $timestamps = false;
public function suppliers()
{
return $this->hasMany(Suppliers::class);
}
}

18
app/Models/Cards.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use App\User;
use Illuminate\Database\Eloquent\Model;
class Cards extends Model
{
protected $fillable = [
'user_id',
'token',
];
public function user()
{
return $this->belongsTo(User::class);
}
}

40
app/Models/Categories.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use App\User;
use App\Models\Suppliers;
use App\Models\Postulations;
use App\Models\CurrentContracts;
use App\Models\FinishedContracts;
use Illuminate\Database\Eloquent\Model;
class Categories extends Model
{
protected $fillable = [
'name',
'en_name'
];
public $timestamps = false;
public function suppliers()
{
return $this->hasMany(Suppliers::class);
}
public function postulations()
{
return $this->hasMany(Postulations::class);
}
public function currentcontracts()
{
return $this->hasMany(CurrentContracts::class);
}
public function finishedcontracts()
{
return $this->hasMany(FinishedContracts::class);
}
}

29
app/Models/Coupon.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace App\Models;
use App\Models\CurrentContracts;
use App\Models\FinishedContracts;
use Illuminate\Database\Eloquent\Model;
class Coupon extends Model
{
//
protected $fillable = [
'name',
'percentage',
'amount',
'limit',
'expire_at',
];
public function currentcontracts()
{
return $this->hasMany(CurrentContracts::class);
}
public function finishedcontracts()
{
return $this->hasMany(FinishedContracts::class);
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Models;
use App\User;
use App\Models\Categories;
use App\Models\Suppliers;
use App\Models\Coupon;
use App\Models\Status;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
class CurrentContracts extends Model
{
//
use SpatialTrait;
protected $fillable = [
'user_id',
'supplier_id',
'category_id',
'address',
'int_number',
'references',
'appointment',
'amount',
'details',
'code',
'coupon_id',
'transaction_id',
'status_id',
];
protected $spatialFields = [
'location',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function categories()
{
return $this->belongsTo('App\Models\Categories', 'category_id');
}
public function suppliers()
{
return $this->belongsTo('App\Models\Suppliers', 'supplier_id');
}
public function coupon()
{
return $this->belongsTo(Coupon::class);
}
public function status()
{
return $this->belongsTo(Status::class);
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace App\Models;
use App\User;
use App\Models\Categories;
use App\Models\Suppliers;
use App\Models\Coupon;
use App\Models\Status;
use App\Models\Report;
use App\Models\Payments;
use App\NoHome;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
class FinishedContracts extends Model
{
//
use SpatialTrait;
protected $fillable = [
'user_id',
'supplier_id',
'category_id',
'address',
'int_number',
'references',
'appointment',
'amount',
'details',
'code',
'coupon_id',
'transaction_id',
'score',
'status_id',
];
protected $spatialFields = [
'location',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function categories()
{
return $this->belongsTo('App\Models\Categories', 'category_id');
}
public function suppliers()
{
return $this->belongsTo('App\Models\Suppliers', 'supplier_id');
}
public function coupon()
{
return $this->belongsTo(Coupon::class);
}
public function status()
{
return $this->belongsTo(Status::class);
}
public function payments()
{
return $this->hasOne(Payments::class);
}
public function reports()
{
return $this->hasOne(Report::class);
}
public function nohome()
{
return $this->hasOne(NoHome::class);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use App\User;
use Illuminate\Database\Eloquent\Model;
class LinkedSocialAccount extends Model
{
protected $fillable = [
'provider_name',
'provider_id',
];
public function user()
{
return $this->belongsTo(User::class);
}
}

34
app/Models/Payments.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
namespace App\Models;
use App\Models\FinishedContracts;
use App\Models\Suppliers;
use App\Models\Status;
use Illuminate\Database\Eloquent\Model;
class Payments extends Model
{
//
protected $fillable = [
'contract_id',
'supplier_id',
'amount',
'status_id',
];
public function finishedcontracts()
{
return $this->belongsTo(FinishedContracts::class);
}
public function suppliers()
{
return $this->belongsTo(Suppliers::class);
}
public function status()
{
return $this->belongsTo(Status::class);
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Models;
use App\User;
use App\Models\Categories;
use App\Models\Suppliers;
use App\Models\Status;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
class Postulations extends Model
{
//
use SpatialTrait;
protected $fillable = [
'user_id',
'category_id',
'address',
'int_number',
'references',
'appointment',
'amount',
'details',
'status_id',
];
protected $spatialFields = [
'location',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function categories()
{
return $this->belongsTo('App\Models\Categories', 'category_id');
}
public function suppliers()
{
return $this->hasMany(Suppliers::class);
}
public function status()
{
return $this->belongsTo(Status::class);
}
}

32
app/Models/Status.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use App\Models\FinishedContracts;
use App\Models\CurrentContracts;
use App\Models\Payments;
use Illuminate\Database\Eloquent\Model;
class Status extends Model
{
//
protected $fillable = [
'name',
];
public $timestamps = false;
public function currentcontracts()
{
return $this->hasMany(CurrentContracts::class);
}
public function finishedcontracts()
{
return $this->hasMany(FinishedContracts::class);
}
public function payments()
{
return $this->hasMany(Payments::class);
}
}

79
app/Models/Suppliers.php Normal file
View File

@@ -0,0 +1,79 @@
<?php
namespace App\Models;
use App\User;
use App\iChambaParameter;
use App\Models\Banks;
use App\Models\Categories;
use App\Models\Postulations;
use App\Models\FinishedContracts;
use App\Models\CurrentContracts;
use App\Models\Payments;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
use Illuminate\Database\Eloquent\Model;
class Suppliers extends Model
{
use SpatialTrait;
protected $fillable = [
'company_name',
'membership',
'cover_photo',
'tags',
'RFC',
'CURP',
'clabe',
'bank_id',
'IVA_id',
'ISR_id',
'finished_jobs',
'total_score',
'address',
];
protected $spatialFields = [
'location',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function banks()
{
return $this->belongsTo('App\Models\Banks', 'bank_id');
}
public function categories()
{
return $this->belongsToMany(Categories::class);
}
public function postulations()
{
return $this->belongsToMany(Postulations::class)->withTimestamps();
}
public function payments()
{
return $this->hasMany(Payments::class);
}
public function currentcontracts()
{
return $this->hasMany(CurrentContracts::class);
}
public function finishedcontracts()
{
return $this->hasMany(FinishedContracts::class);
}
public function ichambaparameters()
{
return $this->belongsTo(iChambaParameter::class);
}
}

29
app/NoHome.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace App;
use App\Models\FinishedContracts;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
class NoHome extends Model
{
use SpatialTrait;
//
protected $fillable = [
'contract_id',
'house_photo',
];
protected $spatialFields = [
'location',
];
public function finishedcontracts()
{
return $this->belongsTo(FinishedContracts::class);
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class PasswordReset extends Notification
{
use Queueable;
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Restaurar contraseña')
->line('Estás recibiendo este correo electrónico porque solicitaste una restauración de contraseña de tu cuenta en JobHero.') // Here are the lines you can safely override
->action('Restaurar contraseña', url('password/reset', $this->token))
->line('Si no solicitaste una restauración de contraseña, favor de ignorar este mensaje.');
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Providers;
use App\Services\SocialUserResolver;
use Coderello\SocialGrant\Resolvers\SocialUserResolverInterface;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
class AppServiceProvider extends ServiceProvider
{
/**
* All of the container bindings that should be registered.
*
* @var array
*/
public $bindings = [
SocialUserResolverInterface::class => SocialUserResolver::class,
];
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
//
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Providers;
use Laravel\Passport\Passport;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Passport::routes();
//
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

34
app/Report.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
namespace App;
use App\User;
use App\Models\FinishedContracts;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
//
protected $fillable = [
'contract_id',
'moderator_id',
'veredict',
];
public function finishedcontracts()
{
return $this->belongsTo(FinishedContracts::class);
}
public function user()
{
return $this->belongsTo('App\User', 'moderator_id');
}
public function reportcomments()
{
return $this->hasMany(ReportComment::class);
}
}

29
app/ReportComment.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace App;
use App\User;
use App\Report;
use Illuminate\Database\Eloquent\Model;
class ReportComment extends Model
{
//
protected $fillable = [
'report_id',
'user_id',
'comment',
];
public function reports()
{
return $this->belongsTo(Report::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
}

19
app/Role.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
namespace App;
use App\User;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
protected $fillable = [
'name',
];
public function users()
{
return $this->hasMany(User::class);
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace App\Services;
use Storage;
use App\User;
use App\Models\LinkedSocialAccount;
use Laravel\Socialite\Two\User as ProviderUser;
use Illuminate\Support\Facades\File;
class SocialAccountsService
{
/**
* Find or create user instance by provider user instance and provider name.
*
* @param ProviderUser $providerUser
* @param string $provider
*
* @return User
*/
public function findOrCreate(ProviderUser $providerUser, string $provider): User
{
$linkedSocialAccount = \App\Models\LinkedSocialAccount::where('provider_name', $provider)
->where('provider_id', $providerUser->getId())
->first();
if ($linkedSocialAccount) {
return $linkedSocialAccount->user;
} else {
$user = null;
if ($email = $providerUser->getEmail()) {
$user = User::where('email', $email)->first();
}
if (! $user) {
$user = User::create([
'name' => $providerUser->getName(),
'email' => $providerUser->getEmail(),
'role_id' => '1',
'social_id' => $providerUser->getId() . '_' . $provider,
]);
$user->save();
}
$user->linkedSocialAccounts()->create([
'provider_id' => $providerUser->getId(),
'provider_name' => $provider,
]);
return $user;
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Services;
use Exception;
use Coderello\SocialGrant\Resolvers\SocialUserResolverInterface;
use Illuminate\Contracts\Auth\Authenticatable;
use Laravel\Socialite\Facades\Socialite;
class SocialUserResolver implements SocialUserResolverInterface
{
/**
* Resolve user by provider credentials.
*
* @param string $provider
* @param string $accessToken
*
* @return Authenticatable|null
*/
public function resolveUserByProviderCredentials(string $provider, string $accessToken): ?Authenticatable
{
$providerUser = null;
try {
$providerUser = Socialite::driver($provider)->userFromToken($accessToken);
} catch (Exception $exception) {}
if ($providerUser) {
return (new SocialAccountsService())->findOrCreate($providerUser, $provider);
}
return null;
}
}

94
app/User.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
namespace App;
use App\Role;
use App\Models\LinkedSocialAccount;
use App\Models\Cards;
use App\Models\Suppliers;
use App\Models\Postulations;
use App\Report;
use App\ReportComment;
use Laravel\Passport\HasApiTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Notifications\Notifiable;
use App\Notifications\PasswordReset;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasApiTokens;
use Notifiable;
protected $fillable = [
'name',
'email',
'profile_photo',
'role_id',
'social_id',
'openpay_id',
'password',
'phone',
'openpay_id',
'phone_verified_at'
];
protected $hidden = [
'password',
'remember_token',
];
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
public function linkedSocialAccounts()
{
return $this->hasMany(LinkedSocialAccount::class);
}
public function cards()
{
return $this->hasMany(Cards::class);
}
public function suppliers()
{
return $this->hasOne(Suppliers::class);
}
public function postulations()
{
return $this->hasMany(Postulations::class);
}
public function currentcontracts()
{
return $this->hasMany(CurrentContracts::class);
}
public function finishedcontracts()
{
return $this->hasMany(FinishedContracts::class);
}
public function reports()
{
return $this->hasMany(Report::class);
}
public function reportcomments()
{
return $this->hasMany(ReportComment::class);
}
public function roles()
{
return $this->belongsTo('App\Role', 'role_id');
}
}

18
app/Verify_accounts.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Verify_accounts extends Model
{
protected $fillable = [
'name',
'email',
'password',
'token'
];
protected $hidden = [
'password',
];
}

21
app/iChambaParameter.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace App;
use App\Models\Suppliers;
use Illuminate\Database\Eloquent\Model;
class iChambaParameter extends Model
{
//
protected $fillable = [
'parameter',
'num_value',
'string_value',
];
public function suppliers()
{
return $this->hasMany(Suppliers::class);
}
}

53
artisan Normal file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

55
bootstrap/app.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

2
bootstrap/cache/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

81
composer.json Normal file
View File

@@ -0,0 +1,81 @@
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^8.2.12",
"berkayk/onesignal-laravel": "^1.0",
"coderello/laravel-passport-social-grant": "^2.0",
"fideloper/proxy": "^4.0",
"gonoware/laravel-maps": "^1.3.0",
"grimzy/laravel-mysql-spatial": "^2.1",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "^2.5",
"laravel/framework": "^8.0",
"laravel/passport": "^7.3",
"laravel/socialite": "^4.1",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.8",
"lcobucci/jwt": "^5.1",
"openpay/sdk": "dev-master",
"superbalist/laravel-google-cloud-storage": "^2.2",
"timehunter/laravel-google-recaptcha-v3": "^2.4"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-install-cmd": [
"chmod -R 775 storage",
"chmod -R 755 bootstrap\/cache",
"php artisan optimize:clear",
"php artisan cache:clear"
]
}
}

8253
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

248
config/app.php Normal file
View File

@@ -0,0 +1,248 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'JobHero'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
'secret' => env('SECRET', 'vktxm0tRk6Hvh3fnbSfDMe6We1nQxKCKPnv9Wq5S'),
'pass' => env('PASS', 'wBIIKuDbrxNKzQhAUGiZLoaoQ4MichAN3wP2AP7B'),
'openpay_id' => env('OPENPAY_ID', 'm9k4beuso5az0wjqztvt'),
'openpay_apikey' => env('OPENPAY_APIKEY', 'sk_0eb5d4072ce64a189c1387a423c7d730'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Collective\Html\HtmlServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
/*
* Package Service Providers...
*/
Berkayk\OneSignal\OneSignalServiceProvider::class,
Grimzy\LaravelMysqlSpatial\SpatialServiceProvider::class,
Superbalist\LaravelGoogleCloudStorage\GoogleCloudStorageServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Form' => Collective\Html\FormFacade::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Html' => Collective\Html\HtmlFacade::class,
'Image' => Intervention\Image\Facades\Image::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'OneSignal' => Berkayk\OneSignal\OneSignalFacade::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Str' => Illuminate\Support\Str::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],
];

102
config/auth.php Normal file
View File

@@ -0,0 +1,102 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
];

59
config/broadcasting.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];

103
config/cache.php Normal file
View File

@@ -0,0 +1,103 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
];

147
config/database.php Normal file
View File

@@ -0,0 +1,147 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
];

8
config/debug-server.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
return [
/*
* The host to use when listening for debug server connections.
*/
'host' => 'tcp://127.0.0.1:9912',
];

78
config/filesystems.php Normal file
View File

@@ -0,0 +1,78 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
|
*/
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
'gcs' => [
'driver' => 'gcs',
'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
'key_file' => env('GOOGLE_CLOUD_KEY_FILE', ''), // optional: /path/to/service-account.json
'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), // optional: /default/path/to/apply/in/bucket
'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI', null), // see: Public URLs below
],
],
];

View File

@@ -0,0 +1,166 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Request Method
|--------------------------------------------------------------------------
|
| If not provided, will use curl as default.
| Supported: "guzzle", "curl", if you want to use your own request method,
| please read document.
|
*/
'request_method' => 'curl',
/*
|--------------------------------------------------------------------------
| Enable/Disable Service
|--------------------------------------------------------------------------
| Type: bool
|
| This option is used to disable/enable the service
|
| Supported: true, false
|
*/
'is_service_enabled' => true,
/*
|--------------------------------------------------------------------------
| Host Name
|--------------------------------------------------------------------------
| Type: string
| Default will be empty, assign value only if you want domain check with Google response
| Google reCAPTCHA host name, https://www.google.com/recaptcha/admin
|
*/
'host_name' => '',
/*
|--------------------------------------------------------------------------
| Secret Key
|--------------------------------------------------------------------------
| Type: string
| Google reCAPTCHA credentials, https://www.google.com/recaptcha/admin
|
*/
'secret_key' => env('RECAPTCHA_V3_SECRET_KEY', ''),
/*
|--------------------------------------------------------------------------
| Site Key
|--------------------------------------------------------------------------
| Type: string
| Google reCAPTCHA credentials, https://www.google.com/recaptcha/admin
|
*/
'site_key' => env('RECAPTCHA_V3_SITE_KEY', ''),
/*
|--------------------------------------------------------------------------
| Badge Style
|--------------------------------------------------------------------------
| Type: boolean
| Support:
| - true: the badge will be shown inline within the form, also you can customise your style
| - false: the badge will be shown in the bottom right side
|
*/
'inline' => false,
/*
|--------------------------------------------------------------------------
| Background Badge Style
|--------------------------------------------------------------------------
| Type: boolean
| Support:
| - true: the background badge will be displayed at the bottom right of page
| - false: the background badge will be invisible
|
*/
'background_badge_display' => true,
/*
|--------------------------------------------------------------------------
| Background Mode
|--------------------------------------------------------------------------
| Type: boolean
| Support:
| - true: the script will run on every page if you put init() on the global page
| - false: the script will only be running if there is action defined
|
*/
'background_mode' => false,
/*
|--------------------------------------------------------------------------
| Score Comparision
|--------------------------------------------------------------------------
| Type: bool
| If you enable it, the package will do score comparision from your setting
*/
'is_score_enabled' => true,
/*
|--------------------------------------------------------------------------
| Setting
|--------------------------------------------------------------------------
| Type: array
| Define your score threshold, define your action
| action: Google reCAPTCHA required parameter
| threshold: score threshold
| score_comparision: true/false, if this is true, the system will do score comparision against your threshold for the action
*/
'setting' => [
[
'action' => 'register',
'threshold' => 0.2,
'score_comparision' => true,
],
],
/*
|--------------------------------------------------------------------------
| Setting
|--------------------------------------------------------------------------
| Type: array
| Define a list of ip that you want to skip
*/
'skip_ips' => [
],
/*
|--------------------------------------------------------------------------
| Options
|--------------------------------------------------------------------------
| Custom option field for your request setting, which will be used for RequestClientInterface
|
*/
'options' => [
],
/*
|--------------------------------------------------------------------------
| API JS Url
|--------------------------------------------------------------------------
| Type: string
| Google reCAPTCHA API JS URL
| use:
*/
'api_js_url' => 'https://www.google.com/recaptcha/api.js',
/*
|--------------------------------------------------------------------------
| Site Verify Url
|--------------------------------------------------------------------------
| Type: string
| Google reCAPTCHA API
| please use "www.recaptcha.net" in your code in circumstances when "www.google.com" is not accessible. e.g China
| e.g. https://www.recaptcha.net/recaptcha/api.js
*/
'site_verify_url' => 'https://www.google.com/recaptcha/api/siteverify',
/*
|--------------------------------------------------------------------------
| Language
|--------------------------------------------------------------------------
| Type: string
| https://developers.google.com/recaptcha/docs/language
*/
'language' => 'en',
];

52
config/hashing.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
],
];

94
config/logging.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['daily'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];

136
config/mail.php Normal file
View File

@@ -0,0 +1,136 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
| "sparkpost", "postmark", "log", "array"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => env('MAIL_PORT', 587),
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
/*
|--------------------------------------------------------------------------
| Log Channel
|--------------------------------------------------------------------------
|
| If you are using the "log" driver, you may specify the logging channel
| if you prefer to keep mail messages separate from other log entries
| for simpler reading. Otherwise, the default channel will be used.
|
*/
'log_channel' => env('MAIL_LOG_CHANNEL'),
];

23
config/onesignal.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| One Signal App Id
|--------------------------------------------------------------------------
|
|
*/
'app_id' => '00d23dae-1209-42cc-bea7-e1f17cee27fa',
/*
|--------------------------------------------------------------------------
| Rest API Key
|--------------------------------------------------------------------------
|
|
|
*/
'rest_api_key' => 'NTQwMDY4ZjUtODlmMy00NzAzLTg1ZDItMWNhMDgyOGVkYzRk',
'user_auth_key' => 'YOUR-USER-AUTH-KEY'
);

87
config/queue.php Normal file
View File

@@ -0,0 +1,87 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
|--------------------------------------------------------------------------
|
| Laravel's queue API supports an assortment of back-ends via a single
| API, giving you convenient access to each back-end using the same
| syntax for every one. Here you may define a default connection.
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
/*
|--------------------------------------------------------------------------
| Queue Connections
|--------------------------------------------------------------------------
|
| Here you may configure the connection information for each server that
| is used by your application. A default configuration has been added
| for each back-end shipped with Laravel. You are free to add more.
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
*/
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
'block_for' => 0,
],
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => env('REDIS_QUEUE', 'default'),
'retry_after' => 90,
'block_for' => null,
],
],
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
|--------------------------------------------------------------------------
|
| These options configure the behavior of failed queue job logging so you
| can control which database and table are used to store the jobs that
| have failed. You may change them to any database / table you wish.
|
*/
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];

66
config/services.php Normal file
View File

@@ -0,0 +1,66 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook' => [
'secret' => env('STRIPE_WEBHOOK_SECRET'),
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
],
],
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_CALLBACK_URL'),
],
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => env('GOOGLE_CALLBACK_URL'),
],
'apple' => [
'client_id' => env('APPLE_CLIENT_ID'),
'client_secret' => env('}APPLE_CLIENT_SECRET'),
'redirect' => env('APPLE_CALLBACK_URL'),
],
];

199
config/session.php Normal file
View File

@@ -0,0 +1,199 @@
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "dynamodb", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Encryption
|--------------------------------------------------------------------------
|
| This option allows you to easily specify that all of your session data
| should be encrypted before it is stored. All encryption will be run
| automatically by Laravel and you can use the Session like normal.
|
*/
'encrypt' => false,
/*
|--------------------------------------------------------------------------
| Session File Location
|--------------------------------------------------------------------------
|
| When using the native session driver, we need a location where session
| files may be stored. A default has been set for you but a different
| location may be specified. This is only needed for file sessions.
|
*/
'files' => storage_path('framework/sessions'),
/*
|--------------------------------------------------------------------------
| Session Database Connection
|--------------------------------------------------------------------------
|
| When using the "database" or "redis" session drivers, you may specify a
| connection that should be used to manage these sessions. This should
| correspond to a connection in your database configuration options.
|
*/
'connection' => env('SESSION_CONNECTION', null),
/*
|--------------------------------------------------------------------------
| Session Database Table
|--------------------------------------------------------------------------
|
| When using the "database" session driver, you may specify the table we
| should use to manage the sessions. Of course, a sensible default is
| provided for you; however, you are free to change this as needed.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Cache Store
|--------------------------------------------------------------------------
|
| When using the "apc", "memcached", or "dynamodb" session drivers you may
| list a cache store that should be used for these sessions. This value
| must match with one of the application's configured cache "stores".
|
*/
'store' => env('SESSION_STORE', null),
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
| Session Cookie Name
|--------------------------------------------------------------------------
|
| Here you may change the name of the cookie used to identify a session
| instance by ID. The name specified here will get used every time a
| new session cookie is created by the framework for every driver.
|
*/
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => env('SESSION_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| HTTPS Only Cookies
|--------------------------------------------------------------------------
|
| By setting this option to true, session cookies will only be sent back
| to the server if the browser has a HTTPS connection. This will keep
| the cookie from being sent to you if it can not be done securely.
|
*/
'secure' => env('SESSION_SECURE_COOKIE', false),
/*
|--------------------------------------------------------------------------
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| do not enable this as other CSRF protection services are in place.
|
| Supported: "lax", "strict"
|
*/
'same_site' => "none",
];

36
config/view.php Normal file
View File

@@ -0,0 +1,36 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Storage Paths
|--------------------------------------------------------------------------
|
| Most templating systems load templates from disk. Here you may specify
| an array of paths that should be checked for your views. Of course
| the usual Laravel view path has already been registered for you.
|
*/
'paths' => [
resource_path('views'),
],
/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the storage
| directory. However, as usual, you are free to change this value.
|
*/
'compiled' => env(
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
];

9
cron.yaml Normal file
View File

@@ -0,0 +1,9 @@
cron:
- description: "Delete expired postulations"
url: /postulations/delete-expired
schedule: 1 of jan 00:10
target: default
- description: 'Delete missed contracts'
url: /currentcontracts/delete-missed
schedule: 1 of jan 00:10
target: default

2
database/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.sqlite
*.sqlite-journal

View File

@@ -0,0 +1,27 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\User;
use Illuminate\Support\Str;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'phone_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
});

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateIChambaParametersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('i_chamba_parameters', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('parameter');
$table->float('num_value')->nullable();
$table->string('string_value')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('i_chamba_parameters');
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('roles', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('roles');
}
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique()->nullable();
$table->string('profile_photo')->nullable();
$table->BigInteger('role_id')->unsigned()->nullable();
$table->string('social_id')->unique()->nullable();
$table->string('openpay_id')->unique()->nullable();
$table->string('phone')->unique()->nullable();
$table->timestamp('phone_verified_at')->nullable();
$table->string('password')->nullable();
$table->boolean('reported')->default(false);
$table->Integer('strikes')->nullable()->default(0);
$table->rememberToken();
$table->timestamps();
$table->foreign('role_id')->references('id')->on('roles')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLinkedSocialAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('linked_social_accounts', function (Blueprint $table) {
$table->increments('id');
$table->string('provider_id');
$table->string('provider_name');
$table->unsignedBigInteger('user_id');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('linked_social_accounts');
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateVerifyAccounts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('verify_accounts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email');
$table->string('password');
$table->string('token')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('verify_accounts');
}
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCardsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cards', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id');
$table->string('token');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cards');
}
}

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBanksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('banks', function (Blueprint $table) {
$table->bigIncrements('id');
$table->Integer('code');
$table->string('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('banks');
}
}

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