Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webdevdea's avatar

Error -> Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'clientSites.id' in 'where clause' (SQL: select * from `clientSites` where `clientSites`.`id` = {ClientSites} limit 1)

This is the code in my route [code]Route::get('/edit/{ClientSite}','PagesController@edit'); Route::post('/edit', 'PagesController@doEdit');[/code] This is my controller code [code] public function edit($clientID) { // get the clientsite $ClientSite = ClientSite::find($clientID);

    // show the edit form and pass the clientsite
    return View::make('edit')
        ->with('ClientSite', $ClientSite);
}

     public function doEdit()
     {
        $ClientSite = ClienSite::findOrFail(Input::get('clientID'));
        $ClientSite->siteName = Input::get('siteName');
        $ClientSite->description = Input::get('description');

        $ClientSite->save();

        return Redirect::action('PagesController@home');
     }[/code]

and this in my view [code]

Edit client {{ $ClientSites->clientID }}

        {{ Form::open(['url'=> '/edit', 'class'=>'form']) }}
        {{ Form::hidden('clientID', $ClientSites->clientID) }}

        <div class="form=group">
            {{ Form::label('siteName', 'siteName:') }}
            {{ Form::text('siteName', $ClientSites->siteName,['class' => 'form-control']) }}
        </div>
        <div class="form=group">
            {{ Form::label('description', 'description:') }}
            {{ Form::textarea('description', $ClientSites->description,['class' => 'form-control']) }}
        </div>[/code]
0 likes
35 replies
fraserk's avatar

Can you verify you have an id field in the clientSites table?

bashy's avatar

Check what this returns

return Input::get('clientID');

dat title length

bashy's avatar

We can see the code but you need to debug it yourself. Try see where it's going wrong by returning parts of the code.

webdevdea's avatar

Thank you bashy, I am trying, Like I said I am new to this and am trying to figure it out myself.

fraserk's avatar

In the clientsite model try

public static $key = 'clientID';
fraserk's avatar

Sorry that should be

protected $primaryKey = 'clientID';
fraserk's avatar

what error are you get now? I just look at you code on line 19 of ClientSite model add ;

webdevdea's avatar

Thanks, yeah I caught that.. I am getting this class not found error.

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)

Class 'ClientSites' not found

fraserk's avatar

In your controller, you should be calling ClientSite:: not ClientSites

webdevdea's avatar

Awesome, I am not getting an error now but a dump I think? string(70) "select * from clientSites where clientSites.clientID = ? limit 1"

webdevdea's avatar

Getting closer to a solution it seems. I am not getting this error

ErrorException (E_UNKNOWN)

Trying to get property of non-object (View: /Applications/MAMP/htdocs/DynamiX3/app/views/edit.blade.php)

fraserk's avatar

Whats the line # that's giving the error?

webdevdea's avatar
  1. Illuminate\View\Engines\CompilerEngine handleViewException …/­vendor/­laravel/­framework/­src/­Illuminate/­View/­Engines/­PhpEngine.php41
webdevdea's avatar

If I change it to the name of the table in the database i get this error. Undefined variable: ClientSites (View: /Applications/MAMP/htdocs/DynamiX3/app/views/edit.blade.php)

fraserk's avatar

It should be ClientSite. on the edit page are you passing in a cliendId in the url.. example.com/edit/1

webdevdea's avatar

I get this error ErrorException (E_UNKNOWN)

Trying to get property of non-object (View: /Applications/MAMP/htdocs/DynamiX3/app/views/edit.blade.php)

fraserk's avatar

I see, on the edit view you using $ClientsSites but in you controlller you're sending $ClientSite

You can change

this 
return View::make('edit')->with('ClientSite', $ClientSite);

to
return View::make('edit')->with('ClientSites', $ClientSite);
webdevdea's avatar

ErrorException (E_UNKNOWN)

Undefined variable: ClientSite (View: /Applications/MAMP/htdocs/DynamiX3/app/views/edit.blade.php) [code]return View::make('edit')->with('ClientSites', $ClientSite); [/code] [code]Route::get('/edit/{clientSite}','PagesController@edit');[/code]

keevitaja's avatar

You are passing ClientSites (plural) to your view but try to access ClientSite (singular)

fraserk's avatar

check your edit view file, be sure all you variables are $clientSites. you still have this in the edit view

{{ Form::hidden('clientID', $ClientSite->clientID) }}
webdevdea's avatar

Changed them all to $clientSites and get this error

ErrorException (E_UNKNOWN)

Undefined variable: clientSites (View: /Applications/MAMP/htdocs/DynamiX3/app/views/edit.blade.php)

keevitaja's avatar

Then $ClientSites is not an object. dd() it in your controller and see what it is!

fraserk's avatar

no on edit view line 20 still have $ClientSite, unless you didnt comit the changes

{{ Form::hidden('clientID', $ClientSite->clientID) }}
webdevdea's avatar

keevitaja I will have to google what you are saying to do and get back with you on that one, I am very very new to this framework.. thank you in advance

webdevdea's avatar

keevitaja , I have this dd($clientSites);
I stuck it on there and it does not change anything

Next

Please or to participate in this conversation.