I have a Laravel 5 project running perfectly on localhost. I uploaded the project to a webhost and suddenly i get an error on a simple class.
This is the error:
FatalThrowableError in HomeController.php line 20:
Fatal error: Class 'App\Blogpost' not found
The Homecontroller code is this:
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Blogpost;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$blogposts = Blogpost::latest()->take(6)->get();
return view('pages/start', compact('blogposts'));
}
}
This code is pretty basic and works fine on localhost so i assume that the problem is located elsewhere, but i'm not sure where to begin searching?
For testing purposes i put all the code from Homecontroller in comments and than i just get an error on something else so the problem is situated elsewhere.
My localhost runs on MAMP with a Apache Server with PHP 7.0.0 . Hosting runs on Linux + Apache + PHP 7.0.5 .
I have uploaded other laravel projects to the same server with the same configuration without any problems.
this is the link if that helps: [http://dev.mayan-co.com][1]
Extra code to show the Blogpost class itself (still pretty sure the problem is not in that class)
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;
class BlogPost extends Model implements SluggableInterface
{
protected $table = "blogposts";
use SluggableTrait;
protected $sluggable = [
'build_from' => 'title',
'save_to' => 'slug',
];
protected $fillable = [
'title',
'featured_image',
'video_key',
'body',
'summary'
];
public function tags()
{
return $this->belongsToMany('App\Tag', "blog_tag", "blogpost_id")->withTimestamps();
}
public function delete()
{
\File::delete([
$this->featured_image,
]);
parent::delete();
}
}
Your filename is BlogPost.php
, yet your class is declared and instantiated as Blogpost
. The filename and classname need to be identical in both name and case.
OSX is not case sensitive like most versions of linux hence why this is not happening to you on your local version.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments