Skip to content

Commit def1724

Browse files
committed
init
0 parents  commit def1724

File tree

201 files changed

+69633
-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.

201 files changed

+69633
-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=homes
11+
DB_USERNAME=homest
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_APP_KEY=
32+
PUSHER_APP_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

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/node_modules
2+
/public/storage
3+
/public/hot
4+
/storage/*.key
5+
/vendor
6+
/.idea
7+
Homestead.json
8+
Homestead.yaml
9+
.env
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
/*
4+
* Sometime too hot the eye of heaven shines
5+
*/
6+
7+
namespace App\Api\Controllers;
8+
9+
use App\Http\Controllers\Controller;
10+
use App\Http\Requests\PostCreateRequest;
11+
use App\Http\Requests\PostUpdateRequest;
12+
use App\Post;
13+
use Carbon\Carbon;
14+
use Illuminate\Support\Facades\Auth;
15+
use Illuminate\Support\Facades\Storage;
16+
17+
class PostController extends Controller
18+
{
19+
public function __construct()
20+
{
21+
22+
}
23+
24+
public function create(PostCreateRequest $request)
25+
{
26+
//save post content to file
27+
Storage::put($request['title'].'.md', $request['content']);
28+
29+
//db
30+
if ($post = Post::create(['title' => $request['title']])) {
31+
$postId = $post->id;
32+
return response()->json(compact('postId'));
33+
}
34+
}
35+
36+
public function index()
37+
{
38+
$posts = [];
39+
40+
//transform
41+
foreach (Post::all() as $key => $value) {
42+
$posts[$key]['id'] = $value['id'];
43+
$posts[$key]['title'] = $value['title'];
44+
$posts[$key]['date'] = Carbon::parse($value['created_at'])->toDateString();
45+
}
46+
47+
return response()->json(['data' => $posts]);
48+
}
49+
50+
public function show($id)
51+
{
52+
$postRaw = Post::find($id);
53+
54+
//transform
55+
$post['id'] = $postRaw['id'];
56+
$post['title'] = $postRaw['title'];
57+
$post['date'] = Carbon::parse($postRaw['created_at'])->toDateString();
58+
$post['content'] = Storage::get($postRaw['title'].'.md');
59+
60+
return response()->json(['data' => $post]);
61+
}
62+
63+
public function update($id, PostUpdateRequest $request)
64+
{
65+
$post = Post::find($id);
66+
67+
//delete old file
68+
Storage::delete($post['title'].'.md');
69+
70+
//save new file
71+
Storage::put($request['title'].'.md', $request['content']);
72+
73+
//update
74+
if ($post = $post->update(['title' => $request['title']])) {
75+
return response()->json(['data' => ['postId' => $id]]);
76+
}
77+
78+
79+
}
80+
81+
public function destroy($id)
82+
{
83+
if (Post::destroy($id)) {
84+
return response()->json();
85+
}
86+
}
87+
}

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+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class AdminController extends Controller
8+
{
9+
public function index()
10+
{
11+
return view('admin.home');
12+
}
13+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Foundation\Auth\AuthenticatesUsers;
7+
8+
class LoginController extends Controller
9+
{
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Login Controller
13+
|--------------------------------------------------------------------------
14+
|
15+
| This controller handles authenticating users for the application and
16+
| redirecting them to your home screen. The controller uses a trait
17+
| to conveniently provide its functionality to your applications.
18+
|
19+
*/
20+
21+
use AuthenticatesUsers;
22+
23+
/**
24+
* Where to redirect users after login.
25+
*
26+
* @var string
27+
*/
28+
protected $redirectTo = '/';
29+
30+
31+
public function username()
32+
{
33+
return 'account';
34+
}
35+
36+
/**
37+
* Create a new controller instance.
38+
*
39+
* @return void
40+
*/
41+
public function __construct()
42+
{
43+
$this->middleware('guest', ['except' => 'logout']);
44+
}
45+
46+
public function redirectTo()
47+
{
48+
return $this->redirectTo;
49+
}
50+
}

0 commit comments

Comments
 (0)