P
P
PRIZRAKeee2017-08-30 10:25:02
Laravel
PRIZRAKeee, 2017-08-30 10:25:02

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,
    ]);
  }
}

routes.php code:
Route::any('contact', ['as' => 'contact.index', 'uses' => '[email protected]']);

View code:
@extends('template')
@section('content')
    <div class="www2">
        @include('blocks.bread')
        <div class="title">Страница контактов</div>
    </div>
@endsection

It writes the following in the error logs:
PHP Fatal error: Class 'App\Http\Controllers\Settings' not found in site_url/app/Http/Controllers/ContactController.php on line 18\
It swears at the line in the controller: I don't know what parameter should be passed and where to get it from. help me please
if (Settings::get('contact_on_page')) {

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Lysenko, 2017-08-30
@PRIZRAKeeee

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 question

Ask a Question

731 491 924 answers to any question