Support the ongoing development of Laravel.io →
posted 7 years ago
Database
Last updated 2 years ago.
0

Try use DB; at the top of your file instead of directly using the Facade class

0

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'));
        }
    }
}
Last updated 7 years ago.
0
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

how about this?

Last updated 7 years ago.
0

look at my first post in thread :) it's the frist way i have tried

0

Sign in to participate in this thread!

Eventy

Your banner here too?

slkt kubakukla Joined 13 Sep 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.