I'm using laravel 5.8 and I want to use access global config() in Request validation class but it does not work
namespace App\Http\Requests;
use App\AppConstant;
use Illuminate\Foundation\Http\FormRequest;
class Something extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'url' => 'required',
'category' => 'in:'.implode(",", config('app.categories').''
];
}
}
and here is part of my config/app.php
return [
'name' => env('APP_NAME', 'Laravel'),
'categories' => [
'games',
'entertainment'
],
but the output is
Class App\Http\Requests\Something does not exist
when i remove config() from request file it works very well
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2JLSmJ5
via IFTTT
Aucun commentaire:
Enregistrer un commentaire