dimanche 23 août 2020

Validation Request Class not Found In Laravel

I am receiving error Class App\Http\Requests\PostStore Not Found

My Contoller Code

namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Http\Requests\PostStore;
class PostController extends Controller
{

 public function store(PostStore $request)
{
    //
    return redirect()->back();
}
}

and request code looks like

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PostStore 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 [
        //
        'title' => 'min:20|max:200|required|string',
        'content' => 'min:20|max:400|required'
    ]
}
public function messages()
{
    return [
    'title.required' => ' :attribute is required',
    'content.required' => ' :attribute is required'
    ]
}
}

I have used

composer dump-autoload

PHP artisan cache:clear,

composer clear-cache,

But it dose not work for me Thank You For Your Help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire