Fix Laravel 5.5 compatibility issues - view helpers, collections, and auth routes

- Replace {{ url() }} with {{ url('/') }} in all blade templates to fix object-to-string conversion errors
- Update TeamStoreModel::selectTeamStoreGroupByCartKey() to use first() instead of get() for Laravel 5.5 Collections
- Fix TeamStoreController to access object properties directly instead of using array syntax [0]
- Update authentication routes to use Laravel 5.5 method names (showLoginForm, login, logout)
- Update login/register links from /auth/login to /login throughout views (navbar, app, auth pages)
- Verify cart, login, and register pages working with HTTP 200 status
This commit is contained in:
Frank John Begornia
2026-01-14 21:44:34 +08:00
parent 56f2f19422
commit 59fc920498
37 changed files with 4224 additions and 1536 deletions

View File

@@ -1,42 +1,64 @@
<?php namespace App\Exceptions;
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler {
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
return $request->expectsJson()
? response()->json(['message' => 'Unauthenticated.'], 401)
: redirect()->guest(route('login'));
}
}

View File

@@ -1,40 +1,32 @@
<?php namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AuthController extends Controller {
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
| This controller handles authenticating users for the application.
|
*/
use AuthenticatesAndRegistersUsers;
use AuthenticatesUsers;
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
* @return void
*/
public function __construct(Guard $auth, Registrar $registrar)
public function __construct()
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
$this->middleware('guest')->except('logout');
}
}

View File

@@ -0,0 +1,68 @@
<?php namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}

View File

@@ -1,11 +1,12 @@
<?php namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
abstract class Controller extends BaseController {
use DispatchesCommands, ValidatesRequests;
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@@ -50,7 +50,7 @@ class MainController extends Controller {
$categoryids = array();
foreach($data as $row){
$categoryids[] = $row->Category;
$categoryids[] = (string)$row->Category;
}
$array_sports = $m->selectSportsByURL($url);

View File

@@ -591,7 +591,7 @@ class TeamStoreController extends Controller
//var_dump($items_group);
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
if ($grouped_item) {
$defId = $grouped_item[0]->StoreId;
$defId = $grouped_item->StoreId;
} else {
$defId = 0;
}

View File

@@ -10,12 +10,31 @@ class Kernel extends HttpKernel {
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
'App\Http\Middleware\VerifyCsrfToken',
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\Illuminate\Cookie\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
/**
@@ -24,14 +43,17 @@ class Kernel extends HttpKernel {
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'teamstoresession' => 'App\Http\Middleware\CheckTeamStorePassword',
'admin' => '\App\Http\Middleware\IsAdmin',
'normaluser' => '\App\Http\Middleware\IsUser',
'isAuthorized' => '\App\Http\Middleware\isAuthorized',
'cors' => 'App\Http\Middleware\Cors',
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'teamstoresession' => \App\Http\Middleware\CheckTeamStorePassword::class,
'admin' => \App\Http\Middleware\IsAdmin::class,
'normaluser' => \App\Http\Middleware\IsUser::class,
'isAuthorized' => \App\Http\Middleware\isAuthorized::class,
'cors' => \App\Http\Middleware\Cors::class,
];
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}

View File

@@ -27,8 +27,8 @@ class MainModel extends Model {
function selectSportsId($url) //
{
$i = DB::table('sports')->where('URL', '=', $url)->get();
$id = $i[0]->Id;
$i = DB::table('sports')->where('URL', '=', $url)->first();
$id = $i->Id;
$k = DB::table('templates')->where('SportsId', '=', $id)
->where('IsActive','=', "TRUE")
@@ -146,8 +146,8 @@ class MainModel extends Model {
function selectTemplatesByCategory($url, $cat) //
{
$i = DB::table('sports')->where('URL', '=', $url)->get();
$id = $i[0]->Id;
$i = DB::table('sports')->where('URL', '=', $url)->first();
$id = $i->Id;
$k = DB::table('templates')->where('SportsId', '=', $id)
->where('Category','=', $cat)

View File

@@ -53,7 +53,7 @@ class TeamStoreModel extends Model {
$i = DB::table('cart_tmp')
->where('CartKey', $cartKey)
->groupby('CartKey')
->get();
->first();
return $i;
}

View File

@@ -1,24 +1,20 @@
<?php namespace App\Providers;
<?php
namespace App\Providers;
use Illuminate\Bus\Dispatcher;
use Illuminate\Support\ServiceProvider;
class BusServiceProvider extends ServiceProvider {
class BusServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @param \Illuminate\Bus\Dispatcher $dispatcher
* @return void
*/
public function boot(Dispatcher $dispatcher)
public function boot()
{
$dispatcher->mapUsing(function($command)
{
return Dispatcher::simpleMapping(
$command, 'App\Commands', 'App\Handlers\Commands'
);
});
// Command bus mapping removed in Laravel 5.5+
// Commands are now auto-discovered
}
/**
@@ -30,5 +26,4 @@ class BusServiceProvider extends ServiceProvider {
{
//
}
}

View File

@@ -19,12 +19,11 @@ class EventServiceProvider extends ServiceProvider {
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
public function boot()
{
parent::boot($events);
parent::boot();
//
}

View File

@@ -1,44 +1,69 @@
<?php namespace App\Providers;
<?php
use Illuminate\Routing\Router;
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
}
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
//
}
$this->mapWebRoutes();
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function($router)
{
require app_path('Http/routes.php');
});
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}