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
Povilas Korop
committed
Aug 23, 2017
0 parents
commit 2f372ca
Showing
1,287 changed files
with
278,725 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,33 @@ | |||
APP_NAME=Laravel | |||
APP_ENV=local | |||
APP_KEY= | |||
APP_DEBUG=true | |||
APP_LOG_LEVEL=debug | |||
APP_URL=http://localhost | |||
|
|||
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 | |||
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= |
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 | Original file line | 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
/node_modules | |||
/public/hot | |||
/public/storage | |||
/storage/*.key | |||
/vendor | |||
/.idea | |||
/.vagrant | |||
Homestead.json | |||
Homestead.yaml | |||
npm-debug.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,40 @@ | |||
<?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 Closure based commands for the application. | |||
* | |||
* @return void | |||
*/ | |||
protected function 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,102 @@ | |||
<?php | |||
namespace App; | |||
|
|||
use Illuminate\Database\Eloquent\Model; | |||
use Carbon\Carbon; | |||
use Illuminate\Database\Eloquent\SoftDeletes; | |||
use Illuminate\Support\Facades\Auth; | |||
|
|||
/** | |||
* Class Course | |||
* | |||
* @package App | |||
* @property string $title | |||
* @property string $slug | |||
* @property text $description | |||
* @property decimal $price | |||
* @property string $course_image | |||
* @property string $start_date | |||
* @property tinyInteger $published | |||
*/ | |||
class Course extends Model | |||
{ | |||
use SoftDeletes; | |||
|
|||
protected $fillable = ['title', 'slug', 'description', 'price', 'course_image', 'start_date', 'published']; | |||
|
|||
|
|||
/** | |||
* Set attribute to money format | |||
* @param $input | |||
*/ | |||
public function setPriceAttribute($input) | |||
{ | |||
$this->attributes['price'] = $input ? $input : null; | |||
} | |||
|
|||
/** | |||
* Set attribute to date format | |||
* @param $input | |||
*/ | |||
public function setStartDateAttribute($input) | |||
{ | |||
if ($input != null && $input != '') { | |||
$this->attributes['start_date'] = Carbon::createFromFormat(config('app.date_format'), $input)->format('Y-m-d'); | |||
} else { | |||
$this->attributes['start_date'] = null; | |||
} | |||
} | |||
|
|||
/** | |||
* Get attribute from date format | |||
* @param $input | |||
* | |||
* @return string | |||
*/ | |||
public function getStartDateAttribute($input) | |||
{ | |||
$zeroDate = str_replace(['Y', 'm', 'd'], ['0000', '00', '00'], config('app.date_format')); | |||
|
|||
if ($input != $zeroDate && $input != null) { | |||
return Carbon::createFromFormat('Y-m-d', $input)->format(config('app.date_format')); | |||
} else { | |||
return ''; | |||
} | |||
} | |||
|
|||
public function teachers() | |||
{ | |||
return $this->belongsToMany(User::class, 'course_user'); | |||
} | |||
|
|||
public function students() | |||
{ | |||
return $this->belongsToMany(User::class, 'course_student')->withTimestamps()->withPivot(['rating']); | |||
} | |||
|
|||
public function lessons() | |||
{ | |||
return $this->hasMany(Lesson::class)->orderBy('position'); | |||
} | |||
|
|||
public function publishedLessons() | |||
{ | |||
return $this->hasMany(Lesson::class)->orderBy('position')->where('published', 1); | |||
} | |||
|
|||
public function scopeOfTeacher($query) | |||
{ | |||
if (!Auth::user()->isAdmin()) { | |||
return $query->whereHas('teachers', function($q) { | |||
$q->where('user_id', Auth::user()->id); | |||
}); | |||
} | |||
return $query; | |||
} | |||
|
|||
public function getRatingAttribute() | |||
{ | |||
return number_format(\DB::table('course_student')->where('course_id', $this->attributes['id'])->average('rating'), 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
<?php | |||
|
|||
namespace App\Exceptions; | |||
|
|||
use Exception; | |||
use Illuminate\Auth\AuthenticationException; | |||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | |||
|
|||
class Handler extends ExceptionHandler | |||
{ | |||
/** | |||
* A list of the exception types that should not be reported. | |||
* | |||
* @var array | |||
*/ | |||
protected $dontReport = [ | |||
\Illuminate\Auth\AuthenticationException::class, | |||
\Illuminate\Auth\Access\AuthorizationException::class, | |||
\Symfony\Component\HttpKernel\Exception\HttpException::class, | |||
\Illuminate\Database\Eloquent\ModelNotFoundException::class, | |||
\Illuminate\Session\TokenMismatchException::class, | |||
\Illuminate\Validation\ValidationException::class, | |||
]; | |||
|
|||
/** | |||
* Report or log an exception. | |||
* | |||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. | |||
* | |||
* @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); | |||
} | |||
|
|||
/** | |||
* Convert an authentication exception into an unauthenticated response. | |||
* | |||
* @param \Illuminate\Http\Request $request | |||
* @param \Illuminate\Auth\AuthenticationException $exception | |||
* @return \Illuminate\Http\Response | |||
*/ | |||
protected function unauthenticated($request, AuthenticationException $exception) | |||
{ | |||
if ($request->expectsJson()) { | |||
return response()->json(['error' => 'Unauthenticated.'], 401); | |||
} | |||
|
|||
return redirect()->guest(route('auth.login')); | |||
} | |||
} |
Oops, something went wrong.