Skip to content

Commit

Permalink
Primer commit
Browse files Browse the repository at this point in the history
  • Loading branch information
casvsv committed Feb 4, 2020
0 parents commit cdb6848
Show file tree
Hide file tree
Showing 46 changed files with 5,365 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
QUEUE_DRIVER=sync
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/vendor
/.idea
Homestead.json
Homestead.yaml
.env
36 changes: 36 additions & 0 deletions app/Cliente.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;

class Cliente extends Model{
protected $table = 'modelo_cliente';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'cedula','nombres','apellidos','genero','estado_civil','fecha_nacimiento','correo','celular','telefono',
];

public $timestamps = false;

/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/

/*
protected $hidden = [
'password',
];
*/

}
Empty file added app/Console/Commands/.gitkeep
Empty file.
29 changes: 29 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\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)
{
//
}
}
33 changes: 33 additions & 0 deletions app/Cuenta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Laravel\Lumen\Auth\Authorizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;

class Cuenta extends Model{
protected $table = 'modelo_cuenta';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'numero','estado','fechaApertura','tipoCuenta','saldo','cliente_id',
];

public $timestamps = false;

/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/

protected $primaryKey = 'cuenta_id';


}
10 changes: 10 additions & 0 deletions app/Events/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;

abstract class Event
{
use SerializesModels;
}
16 changes: 16 additions & 0 deletions app/Events/ExampleEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Events;

class ExampleEvent extends Event
{
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
}
50 changes: 50 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}
109 changes: 109 additions & 0 deletions app/Http/Controllers/ClienteController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace App\Http\Controllers;

use App\Cliente;
use App\Cuenta;
use App\Http\Helper\ResponseBuilder;
use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller as BaseController;



class ClienteController extends BaseController
{
#Listar todos los clientes
public function index(Request $request){
$clientes = Cliente::all();
return response()->json($clientes, 200);
}
#Listar cliente por cedula
public function getCliente(Request $request, $cedula){
if ($request->isjson()){
$cliente = Cliente::where('cedula', $cedula)->get();
#if (!$cliente->isEmpty()){
if(empty($cliente)){
$status = false;
$info = 'Data is not listed successfully';
}
else{
$status = true;
$info = 'Data is listed successfully';
}
return ResponseBuilder::result($status, $info, $cliente);
}
else{
$status = false;
$info = 'Unauthorized';
return ResponseBuilder::result($status, $info);
}
}

#Listar cliente por apellidos
public function getClienteApellidos(Request $request, $apellido){
if ($request->isjson()){
$cliente = Cliente::where('apellidos', $apellido)->get();
#if (!$cliente->isEmpty()){
if(empty($cliente)){
$status = false;
$info = 'Data is not listed successfully';
}
else{
$status = true;
$info = 'Data is listed successfully';
}
return ResponseBuilder::result($status, $info, $cliente);
}
else{
$status = false;
$info = 'Unauthorized';
return ResponseBuilder::result($status, $info);
}
}

#Crear un cliente
public function createCliente(Request $request){
$cliente = new Cliente();
$cuenta = new Cuenta();
$cliente->cedula = $request->cedula;
$cliente->nombres = $request->nombres;
$cliente->apellidos = $request->apellidos;
$cliente->genero = $request->genero;
$cliente->estado_civil = $request->estado_civil;
$cliente->fecha_nacimiento = $request->fecha_nacimiento;
$cliente->correo = $request->correo;
$cliente->telefono = $request->telefono;
$cliente->celular = $request->celular;
$cliente->direccion = $request->direccion;
$cliente->save();
#Generar número de cuenta
$Numero1=rand(9999999, 99999999);
$Numero2=rand(9999999, 99999999);
$Numero=$Numero1*$Numero2;
#
$cuenta->numero = $Numero;
$cuenta->estado = '1';
$cuenta->fechaApertura = $request->fechaApertura;
$cuenta->tipoCuenta = $request->tipoCuenta;
$cuenta->saldo = $request->saldo;
$cuenta->cliente_id = $cliente->id;
$cuenta->save();
//return response()->json($cliente);
}

#Modificar un cliente
public function modifyCliente(Request $request, $cedula){
$cliente = Cliente::where('cedula', $cedula)->first();
if(empty($cliente)){
$status = false;
$info = 'Data is not in the list';
}
else{
#Modificación de datos
$cliente->nombres = $request->nombres;
$cliente->apellidos = $request->apellidos;
$cliente->save();
}
}

}
10 changes: 10 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;

class Controller extends BaseController
{
//
}
43 changes: 43 additions & 0 deletions app/Http/Controllers/CuentaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\Http\Controllers;

use App\Cliente;
use App\Cuenta;
use App\Http\Helper\ResponseBuilder;
use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller as BaseController;



class CuentaController extends BaseController
{
#Listar todos los clientes
public function index(Request $request){
$cuentas = Cuenta::all();
return response()->json($cuentas, 200);
}


#Listar cliente por cedula
public function getCuenta(Request $request, $numero){
if ($request->isjson()){
$cuentas = Cuenta::where('numero', $numero)->get();
#if (!$cliente->isEmpty()){
if(empty($cuentas)){
$status = false;
$info = 'Data is not listed successfully';
}
else{
$status = true;
$info = 'Data is listed successfully';
}
return ResponseBuilder::result($status, $info, $cuentas);
}
else{
$status = false;
$info = 'Unauthorized';
return ResponseBuilder::result($status, $info);
}
}
}
18 changes: 18 additions & 0 deletions app/Http/Controllers/ExampleController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Http\Controllers;

class ExampleController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}

//
}
14 changes: 14 additions & 0 deletions app/Http/Controllers/PruebaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller as BaseController;

class PruebaController extends BaseController
{
public function index(Request $request){
return response()->json("saludo:Hola!");
}
}
Loading

0 comments on commit cdb6848

Please sign in to comment.