lundi 27 février 2017

calling data from database from controller to view using laravel

Controller:

public function index() {
        $data = DB::table('tusers','tbills','tpackages')
            ->join('tbills', 'tusers.user_id', '=', 'tbills.user_id')
            ->join('tpackages', 'tbills.package_id', '=', 'tpackages.package_id')
            ->select('tusers.user_id','tusers.company_name','tusers.first_name', 'tbills.account_no', 'tpackages.package_name','tbills.start_date','tbills.end_date','tbills.bill_status')
            ->get();

        return View::make('account')->with('data',$data);
    }

`

view:

@forelse($data as $value)
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td></td>
                                                <td>

I want to call $data from packagecontroller to account.blade but there is an error

SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "tusers" does not exist
LINE 1: ... "tbills"."end_date", "tbills"."bill_status" from "tusers" i...
^ (SQL: select "tusers"."user_id", "tusers"."company_name", "tusers"."first_name", "tbills"."account_no", "tpackages"."package_name", "tbills"."start_date", "tbills"."end_date", "tbills"."bill_status" from "tusers" inner join "tbills" on "tusers"."user_id" = "tbills"."user_id" inner join "tpackages" on "tbills"."package_id" = "tpackages"."package_id")

Thanks for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire