for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Anavel\Crud\Http\Controllers;
use Anavel\Foundation\Http\Controllers\Controller;
use EasySlugger\Slugger;
use Illuminate\Http\RedirectResponse;
use Anavel\Crud\Contracts\Abstractor\ModelFactory as ModelAbstractorFactory;
use Gate;
class HomeController extends Controller
{
public function index(ModelAbstractorFactory $modelFactory)
$models = config('anavel-crud.models');
if (empty($models)) {
throw new \Exception("No models configured.");
}
foreach ($models as $modelName => $model) {
$modelSlug = Slugger::slugify($modelName);
$modelAbstractor = $modelFactory->getByName($modelSlug);
$config = $modelAbstractor->getConfig();
if (! array_key_exists('authorize', $config) || ($config['authorize'] === true && Gate::allows('adminIndex', $modelAbstractor->getInstance()) || $config['authorize'] === false)) {
return new RedirectResponse(route('anavel-crud.model.index', $modelSlug));
$modelSlug
string
array
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
abort(403);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: