Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2ddb282
Showing
147 changed files
with
264,074 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
APP_DOMAIN=localhost | ||
|
||
SESSION_DOMAIN= | ||
|
||
ADMIN_FIRST_NAME= | ||
ADMIN_LAST_NAME= | ||
ADMIN_EMAIL= | ||
ADMIN_PASSWORD= | ||
|
||
LOG_CHANNEL=stack | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
DB_DATABASE=homestead | ||
DB_USERNAME=homestead | ||
DB_PASSWORD=secret | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
QUEUE_DRIVER=sync | ||
|
||
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 | ||
|
||
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* text=auto | ||
*.css linguist-vendored | ||
*.scss linguist-vendored | ||
*.js linguist-vendored | ||
CHANGELOG.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/node_modules | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
/.idea | ||
/.vscode | ||
/.vagrant | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Customer extends Model | ||
{ | ||
public function assignUser(User $user) | ||
{ | ||
$this->user_id = $user->id; | ||
$this->contact_name = $user->first_name . ' ' . $user->last_name; | ||
$this->contact_email = $user->email; | ||
} | ||
|
||
public function shop() | ||
{ | ||
return $this->belongsTo('App\Shop'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Exception; | ||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
|
||
use Request; | ||
use Illuminate\Auth\AuthenticationException; | ||
use Response; | ||
|
||
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); | ||
} | ||
|
||
/** | ||
* Custom unauthenticated handler, used within auth middleware | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @param AuthenticationException $exception | ||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response | ||
*/ | ||
protected function unauthenticated($request, AuthenticationException $exception) | ||
{ | ||
|
||
/* | ||
* see https://stackoverflow.com/questions/45340855/laravel-5-5-change-unauthenticated-login-redirect-url | ||
$subdomain = request()->route('subdomain'); | ||
if($subdomain){ | ||
return $request->expectsJson() | ||
? response()->json(['message' => $exception->getMessage()], 401) | ||
: redirect()->guest(domain_route('shop.login')); | ||
} | ||
*/ | ||
|
||
return $request->expectsJson() | ||
? response()->json(['message' => $exception->getMessage()], 401) | ||
: redirect()->guest(route('app.login')); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Shop; | ||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
|
||
class DashboardController extends Controller | ||
{ | ||
|
||
public function home() | ||
{ | ||
$shops = Shop::all(); | ||
return view('admin.dashboard', ['shops' => $shops]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
|
||
class LoginController extends Controller | ||
{ | ||
/** | ||
* Create a new controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware('guest')->except('logout'); | ||
} | ||
|
||
public function showLoginForm() | ||
{ | ||
return view('app.login'); | ||
} | ||
|
||
public function handleLogin(Request $request) | ||
{ | ||
|
||
$validatedData = $request->validate([ | ||
'email' => 'required|email|max:255', | ||
'password' => 'required|string', | ||
]); | ||
|
||
$isRemember = $request->input('is_remember'); | ||
|
||
$credentials = $request->only('email', 'password'); | ||
if (auth()->attempt($credentials, $isRemember)) { | ||
return redirect()->intended(route('app.home')); | ||
} | ||
return redirect()->back()->withInput()->withErrors(['login_error' => ['Wrong email or password']]); | ||
} | ||
|
||
public function logout() | ||
{ | ||
auth()->logout(); | ||
return redirect()->route('app.home'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Auth; | ||
|
||
use App\Manager; | ||
use App\Shop; | ||
use App\User; | ||
use Illuminate\Http\Request; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class RegistrationController extends Controller | ||
{ | ||
|
||
|
||
public function showRegistrationForm() | ||
{ | ||
return view('app.registration'); | ||
} | ||
|
||
public function handleRegistration(Request $request) | ||
{ | ||
|
||
$rules = [ | ||
'company_name' => 'required|max:255', | ||
'company_domain' => 'required|unique:shops,domain|max:255', | ||
]; | ||
if (auth()->guest()) { | ||
$rules['first_name'] = 'required|string|max:255'; | ||
$rules['last_name'] = 'required|string|max:255'; | ||
$rules['email'] = 'required|email|max:255'; | ||
$rules['password'] = 'required|string|min:6|confirmed'; | ||
} | ||
$validatedData = $request->validate($rules); | ||
|
||
$shop = new Shop; | ||
$shop->domain = $request->company_domain; | ||
$shop->company_name = $request->company_name; | ||
$shop->is_active = 1; // @todo: activate the shop via email confirmation | ||
$shop->save(); | ||
|
||
if (auth()->check()) { | ||
$user = auth()->user(); | ||
} else { | ||
$user = new User; | ||
$user->first_name = $request->first_name; | ||
$user->last_name = $request->last_name; | ||
$user->email = $request->email; | ||
$user->password = bcrypt($request->password); | ||
$user->save(); | ||
} | ||
|
||
|
||
$owner = new Manager; | ||
$owner->is_owner = 1; | ||
$owner->assignUser($user); | ||
|
||
$shop->owners()->save($owner); | ||
|
||
auth()->login($user, true); | ||
|
||
//@todo emit event | ||
//@todo create new billing - trial period | ||
//@todo send verification/welcome email etc | ||
|
||
// authenticate user and redirect | ||
return redirect()->route('shop.home', ['domain' => $shop->domain]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.