Skip to content

Commit

Permalink
Merge pull request #259 from simde-utc/feature/update-laravel
Browse files Browse the repository at this point in the history
[WIP]Update from Laravel 5.6 to Laravel 5.8
  • Loading branch information
MercierCorentin authored Sep 13, 2019
2 parents eb40a60 + 97432ab commit cf7df0b
Show file tree
Hide file tree
Showing 38 changed files with 1,515 additions and 949 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ BROADCAST_DRIVER=log
CACHE_DRIVER=redis
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=database
QUEUE_CONNECTION=database

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ npm-debug.log
yarn-error.log
.env
.ftpconfig
.phpunit.result.cache

# Front generated filed
public/js/app\.js
public/css/app\.css
Expand All @@ -25,4 +27,4 @@ public/images/articles/*
public/images/assos/*
public/images/events/*
public/images/services/*
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- redis-server

php:
- 7.1.3
- 7.2

before_script:
- cp .env.travis .env
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/Controllers/Resource/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UserController extends Controller
*/
public function __construct()
{
$this->middleware('permission:user', ['except' => ['contributeBde']]);
$this->middleware('permission:user', ['except' => ['contributeBde']]);
$this->middleware('permission:user-contributeBde', ['only' => ['contributeBde']]);
}

Expand Down
3 changes: 2 additions & 1 deletion app/Admin/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Support\Facades\{
DB, Input
};
use Illuminate\Support\Arr;

class Form extends BaseForm
{
Expand Down Expand Up @@ -91,7 +92,7 @@ public function update($model_id, $data=null)
if (!$isEditable) {
return back()->withInput()->withErrors($validationMessages);
} else {
return response()->json(['errors' => array_dot($validationMessages->getMessages())], 422);
return response()->json(['errors' => Arr::dot($validationMessages->getMessages())], 422);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/OldToNew.php
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ protected function addBookings()
'created_by_type' => User::class,
'owned_by_id' => $asso->id,
'owned_by_type' => Asso::class,
'validated_by_id' => ($validated_by->id ?? null),
'validated_by_id' => (isset($validated_by) ? ($validated_by->id ?? null) : null),
'validated_by_type' => User::class,
]);

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Passport/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Str;
use App\Http\Controllers\Controller;
use App\Exceptions\PortailException;
use App\Models\Client;
Expand Down Expand Up @@ -54,7 +55,7 @@ public function store(Request $request)
'user_id' => \Auth::id(),
'asso_id' => $request->asso_id,
'name' => $request->name,
'secret' => str_random(40),
'secret' => Str::random(40),
'redirect' => $request->redirect,
'personal_access_client' => false,
'password_client' => false,
Expand Down
2 changes: 2 additions & 0 deletions app/Models/AuthApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

class AuthApp extends Auth
{
protected $table = "auth_apps";

protected $fillable = [
'user_id', 'app_id', 'password', 'key',
];
Expand Down
2 changes: 2 additions & 0 deletions app/Models/AuthPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

class AuthPassword extends Auth
{
protected $table = "auth_passwords";

protected $fillable = [
'user_id', 'password', 'last_login_at',
];
Expand Down
4 changes: 0 additions & 4 deletions app/Models/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class Comment extends Model implements CanBeOwner, OwnableContract, CanHaveComme
'body', 'created_by_id', 'created_by_type', 'owned_by_id', 'owned_by_type',
];

protected $dates = [
'deleted_at'
];

protected $with = [
'created_by', 'owned_by',
];
Expand Down
1 change: 1 addition & 0 deletions app/Models/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Contact extends Model implements OwnableContract
*/
public static function boot()
{
parent::boot();
$verificator = function ($model) {
if ($type = $model->type) {
if (!preg_match("/$type->pattern/", $model->value)) {
Expand Down
4 changes: 0 additions & 4 deletions app/Models/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class Group extends Model implements CanBeOwner, CanHaveCalendars, CanHaveEvents
'name', 'user_id', 'icon', 'visibility_id',
];

protected $dates = [
'deleted_at',
];

protected $hidden = [
'user_id', 'visibility_id',
];
Expand Down
3 changes: 2 additions & 1 deletion app/Models/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

namespace App\Models;
use Illuminate\Support\Arr;

class Notification extends Model
{
Expand Down Expand Up @@ -55,7 +56,7 @@ public static function boot()
static::creating(function ($model) {
if (isset($model->data['created_by'])) {
$data = $model->data;
$created_by = array_pull($data, 'created_by');
$created_by = Arr::pull($data, 'created_by');
$model->data = $data;

$model->created_by_id = $created_by['id'];
Expand Down
4 changes: 0 additions & 4 deletions app/Notifications/ExternalNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ class ExternalNotification extends Notification
protected $action;

/**
<<<<<<< HEAD
* Notif type and description definition.
=======
* Create an external notification.
>>>>>>> develop
*
* @param CanNotify $model
* @param string $subject
Expand Down
2 changes: 1 addition & 1 deletion app/Pivots/AssoMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function user()
*/
public function asso()
{
return $this->belongsTo(ASso::class);
return $this->belongsTo(Asso::class);
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AuthServiceProvider extends ServiceProvider
'App\Model' => 'App\Policies\ModelPolicy',
];


// It is important to be not deferred because otherwise scopes are not loaded.
protected $defer = false;

Expand Down
3 changes: 2 additions & 1 deletion app/Services/Auth/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Models\User;
use App\Models\AuthApp;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;

class App extends BaseAuth
Expand Down Expand Up @@ -41,7 +42,7 @@ public function addAuth(string $user_id, array $info)
'user_id' => $user_id,
'app_id' => $info['app_id'],
'password' => Hash::make($info['password']),
'key' => str_random(64)
'key' => Str::random()(64)
]);
}
}
42 changes: 21 additions & 21 deletions app/Traits/Model/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getRoleRelationTable()
/**
* List attributed roles.
*
* @return mixed
* @return mixed|null
*/
public function roles()
{
Expand All @@ -63,9 +63,9 @@ public function roles()
/**
* Assing one or several attributed roles depending on given data.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Role_id, semester_id, validated_by_id and user_if can be affected in this array.
* @param boolean $force Enable to by-pass add securities. (to use with caution).
* @param string|array|Collection $roles
* @param array $data Role_id, semester_id, validated_by_id and user_if can be affected in this array.
* @param boolean $force Enable to by-pass add securities. (to use with caution).
* @return mixed
*/
public function assignRoles($roles, array $data=[], bool $force=false)
Expand Down Expand Up @@ -120,10 +120,10 @@ public function assignRoles($roles, array $data=[], bool $force=false)
/**
* Modify one or several attributed roles depending on given data.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Possiblility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param array $updatedData Possibility to affect new role_id, semester_id, validated_by_id and user_id.
* @param boolean $force Enble to By-Pass add scurities (to use with caution).
* @param string|array|Collection $roles
* @param array $data Possiblility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param array $updatedData Possibility to affect new role_id, semester_id, validated_by_id and user_id.
* @param boolean $force Enble to By-Pass add scurities (to use with caution).
* @return mixed
*/
public function updateRoles($roles, array $data=[], array $updatedData=[], bool $force=false)
Expand Down Expand Up @@ -175,10 +175,10 @@ public function updateRoles($roles, array $data=[], array $updatedData=[], bool
/**
* Delete one or several attributed roles depending on given data.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param string $removed_by Person requesting the deletion.
* @param boolean $force By-pass addition securities (to use with caution).
* @param string|array|Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param string $removed_by Person requesting the deletion.
* @param boolean $force By-pass addition securities (to use with caution).
* @return mixed
*/
public function removeRoles($roles, array $data=[], string $removed_by=null, bool $force=false)
Expand Down Expand Up @@ -228,10 +228,10 @@ public function removeRoles($roles, array $data=[], string $removed_by=null, boo
/**
* Synchronize (delete all roles and assign new one.s) one or several attributed roles depending on given data.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param string $removed_by Person requesting the deletion.
* @param boolean $force By-pass addition securities (to use with caution).
* @param string|array|Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match one or several members.
* @param string $removed_by Person requesting the deletion.
* @param boolean $force By-pass addition securities (to use with caution).
* @return mixed
*/
public function syncRoles($roles, array $data=[], string $removed_by=null, bool $force=false)
Expand All @@ -258,8 +258,8 @@ public function syncRoles($roles, array $data=[], string $removed_by=null, bool
/**
* Check if a role in the given list has benn granted or not.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match a membre or several members.
* @param string|array|Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match a membre or several members.
* @return boolean
*/
public function hasOneRole($roles, array $data=[])
Expand All @@ -272,8 +272,8 @@ public function hasOneRole($roles, array $data=[])
/**
* Check if each role in the list exists or not.
*
* @param string|array|Illuminate\Database\Eloquent\Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match a membre or several members.
* @param string|array|Collection $roles
* @param array $data Possibility to use role_id, semester_id, validated_by_id and user_id to match a membre or several members.
* @return boolean
*/
public function hasAllRoles($roles, array $data=[])
Expand All @@ -296,7 +296,7 @@ public function getUserAssignedRoles(string $user_id=null, string $semester_id=n
$semester_id = ($semester_id ?? Semester::getThisSemester()->id);
$roles = $this->roles();

if ($roles === null) {
if (is_null($roles)) {
return collect();
}

Expand Down
32 changes: 20 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{
"name": "simde-utc/portail-api",
"description": "Portail des Assos de l'UTC.",
"keywords": ["framework", "laravel", "simde", "api", "utc", "students", "clubs", "assos"],
"keywords": [
"framework",
"laravel",
"simde",
"api",
"utc",
"students",
"clubs",
"assos"
],
"license": "GPL-v3",
"type": "project",
"require": {
"php": ">=7.1.3",
"php": ">=7.2",
"cybercog/laravel-ownership": "^5.1",
"diadal/passport": "^1.0@dev",
"doctrine/dbal": "^2.6",
Expand All @@ -15,26 +24,26 @@
"ixudra/curl": "^6.16",
"laravel-admin-ext/chartjs": "^1.0",
"laravel-admin-ext/log-viewer": "^1.0",
"laravel/framework": "5.6.*",
"laravel/passport": "6.*",
"laravel/framework": "5.8.*",
"laravel/passport": "7.*",
"laravel/tinker": "~1.0",
"mews/captcha": "^2.2",
"nastuzzi-samy/api-tester": "^1.1",
"nastuzzi-samy/laravel-model-stages": "^1.0",
"nastuzzi-samy/laravel-query-selection": "^2.2",
"phpmd/phpmd": "^2.6",
"predis/predis": "^1.1",
"webpatser/laravel-uuid": "^3.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"fzaninotto/faker": "1.*",
"mockery/mockery": "~1.0",
"nunomaduro/collision": "~1.1",
"nunomaduro/larastan": "=0.3.13",
"phpunit/phpunit": "~7.0",
"nunomaduro/collision": "3.0.*",
"phpunit/phpunit": "~8.0",
"squizlabs/php_codesniffer": "3.*",
"symfony/thanks": "^1.0",
"squizlabs/php_codesniffer": "3.*"
"nunomaduro/larastan": "^0.3.17",
"phpmd/phpmd": "^2.6"
},
"autoload": {
"classmap": [
Expand All @@ -55,8 +64,7 @@
},
"extra": {
"laravel": {
"dont-discover": [
]
"dont-discover": []
}
},
"scripts": {
Expand Down
Loading

0 comments on commit cf7df0b

Please sign in to comment.