Добрый день,
Возможно у меня глупый вопрос, но я не работаю с Laravel.
Пытаюсь создать новую страницу,
1.Создал в httpdocs/app/Http/Requests
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
use Illuminate\Foundation\Http\FormRequest;
class Student21Request extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// only allow updates if the user is logged in
return backpack_auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'fio' => 'required|min:5|max:255',
'image' => 'required',
'title' => 'required|min:5|max:255'
];
}
/**
* Get the validation attributes that apply to the request.
*
* @return array
*/
public function attributes()
{
return [
//
];
}
/**
* Get the validation messages that apply to the request.
*
* @return array
*/
public function messages()
{
return [
//
];
}
}
2. в App/models
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Student21 extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table = 'students21';
protected $primaryKey = 'id';
public $timestamps = true;
protected $guarded = ['id'];
protected $fillable = [
'fio',
'image',
'title',
'block1',
'block2',
'block3',
'block4',
'block5',
'block6',
'text_ru',
'text_kz',
];
// protected $hidden = [];
// protected $dates = [];
/*
|--------------------------------------------------------------------------
| FUNCTIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| SCOPES
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| ACCESORS
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| MUTATORS
|--------------------------------------------------------------------------
*/
}
3. Создал в /routes/web
Route::get('/national-students21', 'PageController@national-students21')->name('national-students21');
Route::get('/national-students21/{id}', 'PageController@national-student21')->name('national-student21');
4.Создал в resources/views файл national-students21.blade.php
@extends('layouts.page')
@section('content')
<div class="independent-judges-wrapper indep-judges-page national-finalists">
<div class="content-title">
<h1>Финалисты Национальной Премии «Учитель Будущего 2021»</h1>
</div>
<div class="indep-judges-wrap">
@if($students21)
@foreach($students21 as $student21)
<div class="indep-judges-item">
<div class="indep-judges-photo">
<img src="/{{$student21->image}}">
</div>
<a href="{{route('national-student21',['id' => $student21->id])}}"></a>
<div class="indep-judges-info">
<h2>{{$student21->fio}}</h2>
<p>{{$student21->title}}</p>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endsection
5.Создал в resources/views файл national-student21.blade.php
@extends('layouts.page')
@section('content')
@if($student21)
<div class="finalist-info">
<div class="finalist-info-main">
<div class="finalist-info-main-photo indep-judges-photo">
<img src="/{{$student21->image}}">
</div>
<div class="finalist-info-main-text">
<h2>{{$student21->fio}}</h2>
<p>{{$student21->title}}</p>
</div>
</div>
<div class="finalist-info-block">
<div class="fi-block-item-wrap">
<div class="fi-block-item">
<p>{!!$student21->block1!!}</p>
</div>
<div>
<p>{!!$student21->block2!!}</p>
</div>
<div class="fi-block-item">
<p>{!!$student21->block3!!}</p>
</div>
</div>
<div class="fi-block-item-wrap">
<div>
<p>{!!$student21->block4!!}</p>
</div>
<div class="fi-block-item">
<p>{!!$student21->block5!!}</p>
</div>
<div>
<p>{!!$student21->block6!!}</p>
</div>
</div>
</div>
<div class="news-show-text">
@if(app()->getLocale() == 'ru')
<p>{!!$student21->text_ru!!}</p>
@else
<p>{!!$student21->text_kz!!}</p>
@endif
</div>
</div>
@endif
@endsection