Search code examples
laravelgithublaravel-bladebootstrap-5

Laravel 101, URL to Route to Controller to View


I'm working on a Laravel project that was working fairly well until I attempted to add Bootstrap 5.3. The problems are certainly something that I introduced, but the entire project became unstable and has devolved into not loading beyond the canned Laravel Jetstream pages. This is Laravel / Vagrant / Homestead, most current versions of everything (as far as I know).

  • URL is pcs2025.test
  • when I browse to pcs2025.test I go to the Jetstream landing page, then to login page, then to dashboard page
  • I added additional pages starting at pcs2025.test/positions. These were working fine. I tried to add styles and functionality with bootstrap. Was going well for a while, then I pulled in some older code and my pages malfunctioned. Bootstrap styling disappeared, no trace of Divs, bootstrap icons, bullets, etc.
  • As I tried to work my way back things got worse, so I ripped everything out and want to start from scratch (plenty of backups, so can get back up to current quickly if I can figure out what happened).
  • I'm testing now with a plain vanilla route/controller/blade, but can't get it to launch.
  • Current status: pcs2025.test launches the Jetstream pages flawlessly (thanks Taylor and team!). pcs2025.test/positions (or pcs2025/postions/1 to pass an id#) goes to a white screen, nothing else.

Second part of the question: How can I version control this entire project to avoid problems like this? I have the entire project on git (admittedly I don't understand it well) but when I try to reset or roll back I always have problems.

Can someone please get me pointed in the right direction? You'll probably have a good laugh in the process. I'm an oldschool OOP .exe programmer, trying to broaden my horizons. I sincerely appreciate all of the work that goes into keeping up with all of this technology...it's a whole different world!

Thanks so much for your help.


Route (mine is the very last line, everything else is Jetstream out of the box):

<?php

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');

    Route::get('/positions', 'App\Http\Controllers\PositionController@show')->name('positions.show');

});

PositionController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Position;
use Illuminate\View\View;
use App\HPosition;
use App\Incumbent;
use Session;
use Auth;
use Illuminate\Support\Facades\Schema\columns;
use Illuminate\Support\Facades\DB;

class PositionController extends Controller
{
    public function show()
    {
        return view('positions.show')
            ->with('id', $id);
    }
}

Resources.Views.positions.show:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Bootstrap demo</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>

Solution

  • Here's what worked:

    • Revert to an earlier commit [ git reset --hard (commit-id) ]
    • Delete the resulting Vendors folder
    • [Composer Install] to rebuild the vendors folder

    Thanks!