Skip to content

Commit e3d1d7d

Browse files
committed
first commit
0 parents  commit e3d1d7d

File tree

100 files changed

+8094
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+8094
-0
lines changed

.env.example

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
APP_ENV=local
2+
APP_KEY=
3+
APP_DEBUG=true
4+
APP_LOG_LEVEL=debug
5+
APP_URL=http://localhost
6+
7+
DB_CONNECTION=mysql
8+
DB_HOST=127.0.0.1
9+
DB_PORT=3306
10+
DB_DATABASE=homestead
11+
DB_USERNAME=homestead
12+
DB_PASSWORD=secret
13+
14+
BROADCAST_DRIVER=log
15+
CACHE_DRIVER=file
16+
SESSION_DRIVER=file
17+
QUEUE_DRIVER=sync
18+
19+
REDIS_HOST=127.0.0.1
20+
REDIS_PASSWORD=null
21+
REDIS_PORT=6379
22+
23+
MAIL_DRIVER=smtp
24+
MAIL_HOST=mailtrap.io
25+
MAIL_PORT=2525
26+
MAIL_USERNAME=null
27+
MAIL_PASSWORD=null
28+
MAIL_ENCRYPTION=null
29+
30+
PUSHER_APP_ID=
31+
PUSHER_KEY=
32+
PUSHER_SECRET=

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/node_modules
2+
/public/storage
3+
/vendor
4+
/.idea
5+
Homestead.json
6+
Homestead.yaml
7+
.env
8+
access_token_tmp

app/Account.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Account extends Model
8+
{
9+
protected $table = 'accounts';
10+
protected $fillable = ['title', 'agency', 'account_number', 'balance', 'balance_initial', 'bank_id'];
11+
12+
public function bank()
13+
{
14+
return $this->belongsTo('App\Bank');
15+
}
16+
}

app/Bank.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Bank extends Model
8+
{
9+
protected $table = 'banks';
10+
protected $fillable = ['title', 'code'];
11+
}

app/Console/Kernel.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')
28+
// ->hourly();
29+
}
30+
31+
/**
32+
* Register the Closure based commands for the application.
33+
*
34+
* @return void
35+
*/
36+
protected function commands()
37+
{
38+
require base_path('routes/console.php');
39+
}
40+
}

app/Exceptions/Handler.php

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Auth\AuthenticationException;
7+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8+
9+
class Handler extends ExceptionHandler
10+
{
11+
/**
12+
* A list of the exception types that should not be reported.
13+
*
14+
* @var array
15+
*/
16+
protected $dontReport = [
17+
\Illuminate\Auth\AuthenticationException::class,
18+
\Illuminate\Auth\Access\AuthorizationException::class,
19+
\Symfony\Component\HttpKernel\Exception\HttpException::class,
20+
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
21+
\Illuminate\Session\TokenMismatchException::class,
22+
\Illuminate\Validation\ValidationException::class,
23+
];
24+
25+
/**
26+
* Report or log an exception.
27+
*
28+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
29+
*
30+
* @param \Exception $exception
31+
* @return void
32+
*/
33+
public function report(Exception $exception)
34+
{
35+
parent::report($exception);
36+
}
37+
38+
/**
39+
* Render an exception into an HTTP response.
40+
*
41+
* @param \Illuminate\Http\Request $request
42+
* @param \Exception $exception
43+
* @return \Illuminate\Http\Response
44+
*/
45+
public function render($request, Exception $exception)
46+
{
47+
return parent::render($request, $exception);
48+
}
49+
50+
/**
51+
* Convert an authentication exception into an unauthenticated response.
52+
*
53+
* @param \Illuminate\Http\Request $request
54+
* @param \Illuminate\Auth\AuthenticationException $exception
55+
* @return \Illuminate\Http\Response
56+
*/
57+
protected function unauthenticated($request, AuthenticationException $exception)
58+
{
59+
if ($request->expectsJson()) {
60+
return response()->json(['error' => 'Unauthenticated.'], 401);
61+
}
62+
63+
return redirect()->guest('login');
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
8+
class AccountsController extends Controller
9+
{
10+
use \App\Http\Controllers\ApiControllerTrait;
11+
12+
protected $model;
13+
protected $relationships = ['bank'];
14+
15+
public function __construct(\App\Account $model)
16+
{
17+
$this->model = $model;
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
8+
class BanksController extends Controller
9+
{
10+
use \App\Http\Controllers\ApiControllerTrait;
11+
12+
protected $model;
13+
14+
public function __construct(\App\Bank $model)
15+
{
16+
$this->model = $model;
17+
}
18+
}
+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
trait ApiControllerTrait
8+
{
9+
/**
10+
* Display a listing of the resource.
11+
*
12+
* @return \Illuminate\Http\Response
13+
*/
14+
public function index(Request $request)
15+
{
16+
$limit = $request->all()['limit'] ?? 20;
17+
18+
$order = $request->all()['order'] ?? null;
19+
if ($order !== null) {
20+
$order = explode(',', $order);
21+
}
22+
$order[0] = $order[0] ?? 'id';
23+
$order[1] = $order[1] ?? 'asc';
24+
25+
$where = $request->all()['where'] ?? [];
26+
27+
$like = $request->all()['like'] ?? null;
28+
if ($like) {
29+
$like = explode(',', $like);
30+
$like[1] = '%' . $like[1] . '%';
31+
}
32+
33+
$result = $this->model->orderBy($order[0], $order[1])
34+
->where(function($query) use ($like) {
35+
if ($like) {
36+
return $query->where($like[0], 'like', $like[1]);
37+
}
38+
return $query;
39+
})
40+
->where($where)
41+
->with($this->relationships())
42+
->paginate($limit);
43+
44+
return response()->json($result);
45+
}
46+
47+
/**
48+
* Store a newly created resource in storage.
49+
*
50+
* @param \Illuminate\Http\Request $request
51+
* @return \Illuminate\Http\Response
52+
*/
53+
public function store(Request $request)
54+
{
55+
$result = $this->model->create($request->all());
56+
return response()->json($result);
57+
}
58+
59+
/**
60+
* Display the specified resource.
61+
*
62+
* @param int $id
63+
* @return \Illuminate\Http\Response
64+
*/
65+
public function show($id)
66+
{
67+
$result = $this->model->with($this->relationships())
68+
->findOrFail($id);
69+
return response()->json($result);
70+
}
71+
72+
/**
73+
* Update the specified resource in storage.
74+
*
75+
* @param \Illuminate\Http\Request $request
76+
* @param int $id
77+
* @return \Illuminate\Http\Response
78+
*/
79+
public function update(Request $request, $id)
80+
{
81+
$result = $this->model->findOrFail($id);
82+
$result->update($request->all());
83+
return response()->json($result);
84+
}
85+
86+
/**
87+
* Remove the specified resource from storage.
88+
*
89+
* @param int $id
90+
* @return \Illuminate\Http\Response
91+
*/
92+
public function destroy($id)
93+
{
94+
$result = $this->model->findOrFail($id);
95+
$result->delete();
96+
return response()->json($result);
97+
}
98+
99+
protected function relationships()
100+
{
101+
if (isset($this->relationships)) {
102+
return $this->relationships;
103+
}
104+
return [];
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7+
8+
class ForgotPasswordController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Password Reset Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller is responsible for handling password reset emails and
16+
| includes a trait which assists in sending these notifications from
17+
| your application to your users. Feel free to explore this trait.
18+
|
19+
*/
20+
21+
use SendsPasswordResetEmails;
22+
23+
/**
24+
* Create a new controller instance.
25+
*
26+
* @return void
27+
*/
28+
public function __construct()
29+
{
30+
$this->middleware('guest');
31+
}
32+
}

0 commit comments

Comments
 (0)