Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 0db7f2c

Browse files
committed
Init
0 parents  commit 0db7f2c

File tree

146 files changed

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

146 files changed

+32982
-0
lines changed

.env.example

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

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/public/build
5+
/resources/assets/less
6+
/storage/*.key
7+
/vendor
8+
/.idea
9+
/.vagrant
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
.env

app/Console/Kernel.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 commands for the application.
33+
*
34+
* @return void
35+
*/
36+
protected function commands()
37+
{
38+
$this->load(__DIR__.'/Commands');
39+
40+
require base_path('routes/console.php');
41+
}
42+
}

app/Episode.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Episode extends Model
8+
{
9+
protected $guarded = [];
10+
protected $casts = [
11+
'published_at' => 'datetime',
12+
];
13+
14+
public function podcast()
15+
{
16+
return $this->belongsTo(Podcast::class);
17+
}
18+
19+
public function scopeRecent($query)
20+
{
21+
return $query->orderBy('published_at', 'desc');
22+
}
23+
24+
public function isVisibleTo($user)
25+
{
26+
return ($this->podcast->isPublished() && $this->isPublished())
27+
|| $this->podcast->isVisibleTo($user);
28+
}
29+
30+
public function isEditableBy($user)
31+
{
32+
return $this->podcast->isOwnedBy($user);
33+
}
34+
35+
public function isPublished()
36+
{
37+
return $this->published_at !== null;
38+
}
39+
40+
public function isFree()
41+
{
42+
return $this->price === null;
43+
}
44+
45+
public function durationForHumans()
46+
{
47+
$hours = (int) floor($this->duration / 60 / 60);
48+
$minutes = (int) round(($this->duration / 60) - ($hours * 60));
49+
50+
return collect([
51+
[$hours, 'hr'],
52+
[$minutes, 'min'],
53+
])->reject(function ($value) {
54+
return $value[0] === 0;
55+
})->flatten(1)->implode(' ');
56+
}
57+
}

app/Exceptions/Handler.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Exception;
6+
use Illuminate\Auth\AuthenticationException;
7+
use Illuminate\Validation\ValidationException;
8+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
9+
10+
class Handler extends ExceptionHandler
11+
{
12+
/**
13+
* A list of the exception types that should not be reported.
14+
*
15+
* @var array
16+
*/
17+
protected $dontReport = [
18+
//
19+
];
20+
21+
/**
22+
* Report or log an exception.
23+
*
24+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
25+
*
26+
* @param \Exception $exception
27+
* @return void
28+
*/
29+
public function report(Exception $exception)
30+
{
31+
parent::report($exception);
32+
}
33+
34+
/**
35+
* Render an exception into an HTTP response.
36+
*
37+
* @param \Illuminate\Http\Request $request
38+
* @param \Exception $exception
39+
* @return \Illuminate\Http\Response
40+
*/
41+
public function render($request, Exception $exception)
42+
{
43+
return parent::render($request, $exception);
44+
}
45+
46+
/**
47+
* Convert a validation exception into a response.
48+
*
49+
* @param \Illuminate\Http\Request $request
50+
* @param \Illuminate\Validation\ValidationException $exception
51+
* @return \Illuminate\Http\Response
52+
*/
53+
protected function invalid($request, ValidationException $exception)
54+
{
55+
$message = $exception->getMessage();
56+
57+
$errors = $exception->validator->errors()->messages();
58+
59+
return $request->expectsJson()
60+
? response()->json(['message' => $message, 'errors' => $errors], 422)
61+
: redirect()->back()->withInput()->withErrors(
62+
$errors, $exception->errorBag
63+
);
64+
}
65+
66+
/**
67+
* Convert an authentication exception into a response.
68+
*
69+
* @param \Illuminate\Http\Request $request
70+
* @param \Illuminate\Auth\AuthenticationException $exception
71+
* @return \Illuminate\Http\Response
72+
*/
73+
protected function unauthenticated($request, AuthenticationException $exception)
74+
{
75+
return $request->expectsJson()
76+
? response()->json(['message' => 'Unauthenticated.'], 401)
77+
: redirect()->guest(route('login'));
78+
}
79+
}
Lines changed: 32 additions & 0 deletions
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+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 = '/home';
29+
30+
/**
31+
* Create a new controller instance.
32+
*
33+
* @return void
34+
*/
35+
public function __construct()
36+
{
37+
$this->middleware('guest')->except('logout');
38+
}
39+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\User;
6+
use App\Http\Controllers\Controller;
7+
use Illuminate\Support\Facades\Validator;
8+
use Illuminate\Foundation\Auth\RegistersUsers;
9+
10+
class RegisterController extends Controller
11+
{
12+
/*
13+
|--------------------------------------------------------------------------
14+
| Register Controller
15+
|--------------------------------------------------------------------------
16+
|
17+
| This controller handles the registration of new users as well as their
18+
| validation and creation. By default this controller uses a trait to
19+
| provide this functionality without requiring any additional code.
20+
|
21+
*/
22+
23+
use RegistersUsers;
24+
25+
/**
26+
* Where to redirect users after registration.
27+
*
28+
* @var string
29+
*/
30+
protected $redirectTo = '/home';
31+
32+
/**
33+
* Create a new controller instance.
34+
*
35+
* @return void
36+
*/
37+
public function __construct()
38+
{
39+
$this->middleware('guest');
40+
}
41+
42+
/**
43+
* Get a validator for an incoming registration request.
44+
*
45+
* @param array $data
46+
* @return \Illuminate\Contracts\Validation\Validator
47+
*/
48+
protected function validator(array $data)
49+
{
50+
return Validator::make($data, [
51+
'name' => 'required|string|max:255',
52+
'email' => 'required|string|email|max:255|unique:users',
53+
'password' => 'required|string|min:6|confirmed',
54+
]);
55+
}
56+
57+
/**
58+
* Create a new user instance after a valid registration.
59+
*
60+
* @param array $data
61+
* @return \App\User
62+
*/
63+
protected function create(array $data)
64+
{
65+
return User::create([
66+
'name' => $data['name'],
67+
'email' => $data['email'],
68+
'password' => bcrypt($data['password']),
69+
]);
70+
}
71+
}

0 commit comments

Comments
 (0)