public function boot()
{
Paginator::useBootstrap();
View::share('newestPosts', Post::with('community')->latest()->take(5)->get());
View::share('newestCommunities', Community::withCount('posts')->latest()->take(5)->get());
PostVote::observe(PostVoteObserver::class);
}
The View::share commands fail because the db on a fresh install is still empty. Migration can't run because this code will run first. This is what happens:
php artisan migrate
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'reddit.posts' doesn't exist (SQL: select * from `posts` where `posts`.`deleted_at` is null order by `created_at` desc limit 5)
at C:\Users\User\projects\php\Laravel-Reddit-Clone-Course\vendor\laravel\framework\src\Illuminate\Database\Connection.php:678
674▕ // If an exception occurs when attempting to run a query, we'll format the error
675▕ // message to include the bindings with SQL, which will make this exception a
676▕ // lot more helpful to the developer instead of just the database's errors.
677▕ catch (Exception $e) {
➜ 678▕ throw new QueryException(
679▕ $query, $this->prepareBindings($bindings), $e
680▕ );
681▕ }
682▕
• A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`.
https://laravel.com/docs/master/migrations#running-migrations
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))
2 C:\Users\User\projects\php\Laravel-Reddit-Clone-Course\vendor\laravel\framework\src\Illuminate\Database\Connection.php:338
PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'reddit.posts' doesn't exist")
The View::share commands fail because the db on a fresh install is still empty. Migration can't run because this code will run first. This is what happens: