Skip to content

Commit

Permalink
Merge pull request #1468 from rappasoft/development
Browse files Browse the repository at this point in the history
Laravel 8
  • Loading branch information
rappasoft authored Oct 21, 2020
2 parents 966f38a + 29b5501 commit 6bb9746
Show file tree
Hide file tree
Showing 98 changed files with 5,042 additions and 2,559 deletions.
6 changes: 1 addition & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ APP_READ_ONLY=false
APP_READ_ONLY_LOGIN=true
DEBUGBAR_ENABLED=false
LOG_CHANNEL=daily
LOG_LEVEL=debug

# Drivers
DB_CONNECTION=mysql
Expand Down Expand Up @@ -69,13 +70,8 @@ PASSWORD_EXPIRES_DAYS=180
# Get your credentials at: https://www.google.com/recaptcha/admin
LOGIN_CAPTCHA_STATUS=false
REGISTRATION_CAPTCHA_STATUS=false

INVISIBLE_RECAPTCHA_SITEKEY=
INVISIBLE_RECAPTCHA_SECRETKEY=
INVISIBLE_RECAPTCHA_BADGEHIDE=false
INVISIBLE_RECAPTCHA_DATABADGE='bottomright'
INVISIBLE_RECAPTCHA_TIMEOUT=5
INVISIBLE_RECAPTCHA_DEBUG=false

# Socialite Providers
FACEBOOK_ACTIVE=false
Expand Down
44 changes: 43 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,46 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [8.0.0] - 2020-10-21

## Added

- Added back roave/security-advisories
- Added new database factories
- Added Polish languages
- Added BladeServiceProvider with @captcha directive
- Added Captcha rule
- Added Captcha configs to boilerplate configs

## Changed

- Update livewire tables to 0.3
- Updated users/roles table to use new tables
- Moved livewire components into Frontend/Backend and updated calls
- Removed type partial and just merged into table format
- Update PHP to 7.3
- Update Guzzle to v7
- Update Laravel to v8
- Update Socialite to v5
- Update Laravel UI to v3
- Update Lockout to v3
- Update Breadcrumbs to v2
- Update PHP Pretty Printer to v0.29
- Update Ignition to v2.3.6
- Update Collision to v5
- Condense .env.example
- Updated tests to use new factories
- Updated seeders and factories to be namespaced
- Follow Laravel upgrade guide for v8 and change all the needed files
- Update to Laravel commit: 8d3ca07c4cff6d36593625ee4b34e19ce2dba15b
- Update CS/FR/IN languages
- Sort locale dropdown by language not array key
- Modified login/register controllers to use new Captcha rule

## Removed

- Remove recaptcha

## [7.2.5] - 2020-08-06

## Changed
Expand Down Expand Up @@ -342,7 +382,9 @@ Started from scratch with a blank Laravel 7.* installation. This release is not
- Fix yarn tests
- Fix: Socially logged in users get assigned the default role

[Unreleased]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.5...development
[Unreleased]: https://github.com/rappasoft/laravel-boilerplate/compare/v8.0.0...development
[8.0.0]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.6...v8.0.0
[7.2.6]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.5...v7.2.6
[7.2.5]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.4...v7.2.5
[7.2.4]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.3...v7.2.4
[7.2.3]: https://github.com/rappasoft/laravel-boilerplate/compare/v7.2.2...v7.2.3
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Laravel Boilerplate (Current: Laravel 7.*) ([Demo](https://demo.laravel-boilerplate.com))
## Laravel Boilerplate (Current: Laravel 8.*) ([Demo](https://demo.laravel-boilerplate.com))

[![Latest Stable Version](https://poser.pugx.org/rappasoft/laravel-boilerplate/v/stable)](https://packagist.org/packages/rappasoft/laravel-boilerplate)
[![Latest Unstable Version](https://poser.pugx.org/rappasoft/laravel-boilerplate/v/unstable)](https://packagist.org/packages/rappasoft/laravel-boilerplate)
Expand All @@ -21,11 +21,9 @@

[Click here for the official documentation](http://laravel-boilerplate.com)

<a href="https://tracking.gitads.io/?repo=laravel-boilerplate"><img src="https://images.gitads.io/laravel-boilerplate" alt="GitAds"/></a>

### Slack Channel

Please join us in our Slack channel to get faster responses to your questions. Get your invite here: https://laravel-boilerplate.herokuapp.com
Please join us in our Slack channel to get faster responses to your questions. Get your invite here: https://laravel-5-boilerplate.herokuapp.com

### Introduction

Expand Down
13 changes: 13 additions & 0 deletions app/Domains/Announcement/Models/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Domains\Announcement\Models;

use App\Domains\Announcement\Models\Traits\Scope\AnnouncementScope;
use Database\Factories\AnnouncementFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

Expand All @@ -12,6 +14,7 @@
class Announcement extends Model
{
use AnnouncementScope,
HasFactory,
LogsActivity;

public const TYPE_FRONTEND = 'frontend';
Expand Down Expand Up @@ -46,4 +49,14 @@ class Announcement extends Model
protected $casts = [
'enabled' => 'boolean',
];

/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return AnnouncementFactory::new();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use App\Domains\Auth\Events\User\UserLoggedIn;
use App\Http\Controllers\Controller;
use App\Rules\Captcha;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;

Expand Down Expand Up @@ -60,7 +60,7 @@ protected function validateLogin(Request $request)
$request->validate([
$this->username() => ['required', 'max:255', 'string'],
'password' => array_merge(['max:100'], PasswordRules::login()),
'g-recaptcha-response' => ['required_if:captcha_status,true', 'captcha'],
'g-recaptcha-response' => ['required_if:captcha_status,true', new Captcha],
], [
'g-recaptcha-response.required_if' => __('validation.required', ['attribute' => 'captcha']),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Domains\Auth\Services\UserService;
use App\Http\Controllers\Controller;
use App\Rules\Captcha;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
Expand Down Expand Up @@ -77,7 +78,7 @@ protected function validator(array $data)
'email' => ['required', 'string', 'email', 'max:255', Rule::unique('users')],
'password' => array_merge(['max:100'], PasswordRules::register($data['email'] ?? null)),
'terms' => ['required', 'in:1'],
'g-recaptcha-response' => ['required_if:captcha_status,true', 'captcha'],
'g-recaptcha-response' => ['required_if:captcha_status,true', new Captcha],
], [
'terms.required' => __('You must accept the Terms & Conditions.'),
'g-recaptcha-response.required_if' => __('validation.required', ['attribute' => 'captcha']),
Expand Down
2 changes: 1 addition & 1 deletion app/Domains/Auth/Listeners/RoleEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function onUpdated($event)
'type' => $event->role->type,
'name' => $event->role->name,
],
'permissions' =>$event->role->permissions->count() ? $event->role->permissions->pluck('description')->implode(', ') : 'None',
'permissions' => $event->role->permissions->count() ? $event->role->permissions->pluck('description')->implode(', ') : 'None',
])
->log(':causer.name updated role :subject.name with permissions: :properties.permissions');
}
Expand Down
15 changes: 14 additions & 1 deletion app/Domains/Auth/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

use App\Domains\Auth\Models\Traits\Attribute\RoleAttribute;
use App\Domains\Auth\Models\Traits\Method\RoleMethod;
use Database\Factories\RoleFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Spatie\Permission\Models\Role as SpatieRole;

/**
* Class Role.
*/
class Role extends SpatieRole
{
use RoleAttribute,
use HasFactory,
RoleAttribute,
RoleMethod;

/**
Expand All @@ -20,4 +23,14 @@ class Role extends SpatieRole
protected $with = [
'permissions',
];

/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return RoleFactory::new();
}
}
15 changes: 14 additions & 1 deletion app/Domains/Auth/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use App\Domains\Auth\Notifications\Frontend\VerifyEmail;
use DarkGhostHunter\Laraguard\Contracts\TwoFactorAuthenticatable;
use DarkGhostHunter\Laraguard\TwoFactorAuthentication;
use Database\Factories\UserFactory;
use Illuminate\Auth\MustVerifyEmail as MustVerifyEmailTrait;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
Expand All @@ -23,7 +25,8 @@
*/
class User extends Authenticatable implements MustVerifyEmail, TwoFactorAuthenticatable
{
use HasRoles,
use HasFactory,
HasRoles,
Impersonate,
MustVerifyEmailTrait,
Notifiable,
Expand Down Expand Up @@ -144,4 +147,14 @@ public function canBeImpersonated(): bool
{
return ! $this->isMasterAdmin();
}

/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return UserFactory::new();
}
}
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Handler extends ExceptionHandler
* @param \Throwable $exception
* @return void
*
* @throws \Exception
* @throws \Throwable
*/
public function report(Throwable $exception)
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http;

use App\Domains\Auth\Models\User;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

/**
Expand Down Expand Up @@ -45,7 +44,7 @@ class Kernel extends HttpKernel
],

'api' => [
'throttle:60,1',
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
<?php

namespace App\Http\Livewire;
namespace App\Http\Livewire\Backend;

use App\Domains\Auth\Models\Role;
use App\Domains\Auth\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\TableComponent;
use Rappasoft\LaravelLivewireTables\Traits\HtmlComponents;
use Rappasoft\LaravelLivewireTables\Views\Column;

/**
* Class RolesTable.
*/
class RolesTable extends TableComponent
{
use HtmlComponents;

/**
* @var string
*/
public $sortField = 'name';

/**
* @var array
*/
protected $options = [
'bootstrap.container' => false,
'bootstrap.classes.table' => 'table table-striped',
];

/**
* @return Builder
*/
Expand All @@ -32,24 +44,37 @@ public function query(): Builder
public function columns(): array
{
return [
Column::make(__('Type'))
->view('backend.auth.role.includes.type', 'role')
->sortable(),
Column::make(__('Name'))
Column::make(__('Type'), 'type')
->sortable()
->format(function (Role $model) {
if ($model->type === User::TYPE_ADMIN) {
return __('Administrator');
}

if ($model->type === User::TYPE_USER) {
return __('User');
}

return 'N/A';
}),
Column::make(__('Name'), 'name')
->searchable()
->sortable(),
Column::make(__('Permissions'), 'permissions_label')
->customAttribute()
->html()
->searchable(function ($builder, $term) {
return $builder->orWhereHas('permissions', function ($query) use ($term) {
return $query->where('name', 'like', '%'.$term.'%');
});
})
->format(function (Role $model) {
return $this->html($model->permissions_label);
}),
Column::make(__('Number of Users'), 'users_count')
->sortable(),
Column::make(__('Actions'))
->view('backend.auth.role.includes.actions'),
->format(function (Role $model) {
return view('backend.auth.role.includes.actions', ['model' => $model]);
}),
];
}
}
Loading

0 comments on commit 6bb9746

Please sign in to comment.