Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .env.travis
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ LARAVEL_BLOCKER_BLADE_PLACEMENT_JS='footer_scripts'
LARAVEL_BLOCKER_USE_TYPES_SEED_PUBLISHED=true
LARAVEL_BLOCKER_USE_ITEMS_SEED_PUBLISHED=true

# Roles Default Models
ROLES_DEFAULT_ROLE_MODEL=jeremykenedy\LaravelRoles\Models\Role
ROLES_DEFAULT_PERMISSION_MODEL=jeremykenedy\LaravelRoles\Models\Permission
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, this is because I changed the models to extend the packages models... correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes !


# Roles database information
ROLES_DATABASE_CONNECTION=null

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: "8.0"
php-version: "8.1"
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,6 @@ LARAVEL_BLOCKER_BLADE_PLACEMENT_JS='footer_scripts'
LARAVEL_BLOCKER_USE_TYPES_SEED_PUBLISHED=true
LARAVEL_BLOCKER_USE_ITEMS_SEED_PUBLISHED=true

# Roles Default Models
ROLES_DEFAULT_ROLE_MODEL=jeremykenedy\LaravelRoles\Models\Role
ROLES_DEFAULT_PERMISSION_MODEL=jeremykenedy\LaravelRoles\Models\Permission

# Roles database information
ROLES_DATABASE_CONNECTION=null

Expand Down
5 changes: 1 addition & 4 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
use App\Mail\ExceptionOccured;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
Expand Down Expand Up @@ -81,7 +78,7 @@ public function render($request, Throwable $e)

if ($userLevelCheck) {
if ($request->expectsJson()) {
return Response::json([
return response()->json([
'error' => 403,
'message' => 'Unauthorized.',
], 403);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/ActivateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use jeremykenedy\LaravelRoles\Models\Role;
use App\Models\Role;

class ActivateController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use jeremykenedy\LaravelRoles\Models\Role;
use App\Models\Role;

class RegisterController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/SocialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Traits\CaptureIpTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use jeremykenedy\LaravelRoles\Models\Role;
use App\Models\Role;
use Laravel\Socialite\Facades\Socialite;

class SocialController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SoftDeletesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Models\User;
use Illuminate\Http\Request;
use jeremykenedy\LaravelRoles\Models\Role;
use App\Models\Role;

class SoftDeletesController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/UsersManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Hash;
use jeremykenedy\LaravelRoles\Models\Role;
use App\Models\Role;
use Validator;

class UsersManagementController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Kernel extends HttpKernel
*
* @var array
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, did the variable name change within Laravel or is this a personal preference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Middleware/CheckCurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Symfony\Component\HttpFoundation\Response;

class CheckCurrentUser
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
if (! $request->user()) {
abort(403, 'Unauthorized action.');
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Middleware/CheckIsUserActivated.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Symfony\Component\HttpFoundation\Response;

class CheckIsUserActivated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
if (config('settings.activation')) {
$user = Auth::user();
Expand Down
12 changes: 2 additions & 10 deletions app/Models/Activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ class Activation extends Model
'ip_address',
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'created_at',
'updated_at',
];

/**
* The attributes that are mass assignable.
*
Expand All @@ -71,6 +61,8 @@ class Activation extends Model
'user_id' => 'integer',
'token' => 'string',
'ip_address' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

/**
Expand Down
20 changes: 6 additions & 14 deletions app/Models/Social.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ class Social extends Model
*/
protected $hidden = [];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'created_at',
'updated_at',
];

/**
* The attributes that are mass assignable.
*
Expand All @@ -63,10 +53,12 @@ class Social extends Model
* @var array
*/
protected $casts = [
'id' => 'integer',
'user_id' => 'integer',
'provider' => 'string',
'social_id' => 'string',
'id' => 'integer',
'user_id' => 'integer',
'provider' => 'string',
'social_id' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

/**
Expand Down
14 changes: 3 additions & 11 deletions app/Models/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ class Theme extends Model
*/
protected $hidden = [];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
];

/**
* Fillable fields for a Profile.
*
Expand Down Expand Up @@ -79,6 +68,9 @@ class Theme extends Model
'activated' => 'boolean',
'taggable_id' => 'integer',
'taggable_type' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];

/**
Expand Down
14 changes: 3 additions & 11 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ class User extends Authenticatable
'token',
];

/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
];

/**
* The attributes that are mass assignable.
*
Expand Down Expand Up @@ -101,6 +90,9 @@ class User extends Authenticatable
'admin_ip_address' => 'string',
'updated_ip_address' => 'string',
'deleted_ip_address' => 'string',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];

public function sendPasswordResetNotification($token)
Expand Down
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function register(): void
*/
public function boot(): void
{
URL::forceScheme('https');
if ($this->app->environment('production')) {
URL::forceScheme('https');
}
//Paginator::useBootstrapThree();
Paginator::useBootstrap();
Schema::defaultStringLength(191);
Expand Down
4 changes: 1 addition & 3 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ class AuthServiceProvider extends ServiceProvider
* @var array<class-string, class-string>
*/
protected $policies = [
'App\Models\Model' => 'App\Policies\ModelPolicy',
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why comment it out?

Copy link
Contributor Author

@maxdestors maxdestors Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was triggering an error if not, to be honest I am not using it in my own project so I never checked how policies works
Uncaught ReflectionException: Class "App\Policies\ModelPolicy" does not exist in Command line code:1

];

/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
$this->registerPolicies();

//
}
}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"predis/predis": "^2.1",
"pusher/pusher-php-server": "^7.2",
"rap2hpoutre/laravel-log-viewer": "^2.3",
"socialiteproviders/37signals": "*",
"socialiteproviders/instagram": "*",
"socialiteproviders/linkedin": "*",
"socialiteproviders/37signals": "^4.1",
"socialiteproviders/instagram": "^5.0",
"socialiteproviders/linkedin": "^4.2",
"socialiteproviders/twitch": "^5.3",
"socialiteproviders/youtube": "*"
"socialiteproviders/youtube": "^4.1"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
Expand Down
2 changes: 1 addition & 1 deletion config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'search_path' => 'public',
'sslmode' => 'prefer',
],

Expand Down
2 changes: 1 addition & 1 deletion config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'default' => env('FILESYSTEM_DRIVER', 'local'),
'default' => env('FILESYSTEM_DISK', 'local'),

/*
|--------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions database/seeders/ConnectRelationshipsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Database\Seeders;

use App\Models\Permission;
use App\Models\Role;
use Illuminate\Database\Seeder;

class ConnectRelationshipsSeeder extends Seeder
Expand All @@ -16,12 +18,12 @@ public function run(): void
/**
* Get Available Permissions.
*/
$permissions = config('roles.models.permission')::all();
$permissions = Permission::all();

/**
* Attach Permissions to Roles.
*/
$roleAdmin = config('roles.models.role')::where('name', '=', 'Admin')->first();
$roleAdmin = Role::where('name', '=', 'Admin')->first();
foreach ($permissions as $permission) {
$roleAdmin->attachPermission($permission);
}
Expand Down
15 changes: 8 additions & 7 deletions database/seeders/PermissionsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Seeders;

use App\Models\Permission;
use Illuminate\Database\Seeder;

class PermissionsTableSeeder extends Seeder
Expand Down Expand Up @@ -49,13 +50,13 @@ public function run(): void
*
*/
foreach ($Permissionitems as $Permissionitem) {
$newPermissionitem = config('roles.models.permission')::where('slug', '=', $Permissionitem['slug'])->first();
if ($newPermissionitem === null) {
$newPermissionitem = config('roles.models.permission')::create([
'name' => $Permissionitem['name'],
'slug' => $Permissionitem['slug'],
'description' => $Permissionitem['description'],
'model' => $Permissionitem['model'],
$newPermissionitem = Permission::where('slug', '=', $Permissionitem['slug'])->first();
if (null === $newPermissionitem) {
$newPermissionitem = Permission::create([
'name' => $Permissionitem['name'],
'slug' => $Permissionitem['slug'],
'description' => $Permissionitem['description'],
'model' => $Permissionitem['model'],
]);
}
}
Expand Down
Loading