Answer the question
In order to leave comments, you need to log in
Why does 500 error appear in laravel?
Hello. I was given the task of creating a new page on the site. Site on laravel. I have never met him before and + I don’t understand php well, so I’m trying to do it by analogy with other controllers. Help solve the problem. I created a controller, a view and connected it in routes.php. But on the page I'm trying to render, the error is GET http://site_url/contact 500 (Internal Server Error)
The code in the controller is:
<?php namespace App\Http\Controllers;
use Fanky\Admin\Models\Page;
class ContactController extends Controller {
public $contact = [];
protected $contact_page;
private $on_page = 1;
public function __construct() {
$this->contact_page = Page::whereAlias('kontakti')
->get(['name', 'alias', 'title', 'description', 'keywords'])
->first();
$this->contact[] = [
'url' => '/contact',
'name' => $this->contact_page->name
];
if (Settings::get('contact_on_page')) {
$this->on_page = Settings::get('contact_on_page');
}
var_dump(2); exit();
}
public function index() {
$bread = $this->contact;
View::share('bread', $bread);
return view('contact.index', [
'name' => $this->contact_page->name,
'title' => $this->contact_page->title,
'keywords' => $this->contact_page->keywords,
'description' => $this->contact_page->description,
]);
}
}
Route::any('contact', ['as' => 'contact.index', 'uses' => '[email protected]']);
@extends('template')
@section('content')
<div class="www2">
@include('blocks.bread')
<div class="title">Страница контактов</div>
</div>
@endsection
if (Settings::get('contact_on_page')) {
Answer the question
In order to leave comments, you need to log in
connect the Settings model at the top
Is there a Settings.php file somewhere?
You must include it as this model
use Fanky\Admin\Models\Page;
only
use path\Settings;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question