Try use DB;
at the top of your file instead of directly using the Facade class
nothing changed.
phpstorm claims that class DB is undefined
namespace App\Http\Controllers;
use App\Site;
use Illuminate\Http\Request;
use DB;
class SiteController extends Controller {
public function actionIndex(Request $request) {
$label = $request->route('label');
if($label) {
$site = DB::table('sites')->where('label', 'like', $label);
return view('site.index')->with('site', $site);
}
else {
$collection = Site::all();
return view('site.index', compact('collection'));
}
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
how about this?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community