Sri Harsha
Sri Harsha

Reputation: 93

Laravel 4.2 save() method is throwing "Error in exception handler."

I am bit new to Laravel. I am trying to insert FORM data into my table. save() method is throwing above mentioned exception. Below are the details. Can someone help finding the issue, Thanks!
I am working on UBUNTU 14.04 OS

route:

Route::get('/', 'HomeController@showHomePage');
Route::post('saveClientData', 'DataController@storeData');

Model:

class client extends Eloquent{
    
    protected $table = 'client';
    
}

Controller:

<?php

class DataController extends BaseController {

/**
 * Stores client data. 
 * 
 */    

public function storeData()
{
        $client = new client();
        $client->clientName = Input::get('clientName');
        $client->clientLocation = Input::get('clientLocation');
        $client->clientBid = Input::get('clientBid');
        
        $client->save();
//            echo 'passed2';
}

}

FORM:

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Laravel PHP Framework</title>
        <link rel="stylesheet" href="/css/styles.css" />
    </head>
    <body>
        <div class="header">
            <h1 id="header-logo">clients.com</h1>
        </div>
        <div class="mypage-form">
            {{ Form::open(array('url' => 'saveClientData')) }}
                <div class="row col-xs-12"><h2>Registration</h2></div>
                <div class="row valid1">
                    <div class="col-xs-12">{{ Form::label('client-name', 'Client Name') }}</div>
                    <div class="col-xs-12 inputstyle">
                        {{ Form::text('clientName') }}
                    </div>
                    <div class="col-xs-12"><span class="error1"></span></div>
                </div> 
                <div class="row valid1">
                    <div class="col-xs-12">{{ Form::label('client-location', 'Client Location') }}</div>
                    <div class="col-xs-12 inputstyle">
                        {{ Form::text('clientLocation') }}
                    </div>
                    <div class="col-xs-12"><span class="error1"></span></div>
                </div>
                <div class="row valid1">
                    <div class="col-xs-12">{{ Form::label('client-bid', 'Client Bid') }}</div>
                    <div class="col-xs-12 inputstyle">
                        {{ Form::text('clientBid') }}
                    </div>
                    <div class="col-xs-12"><span class="error1"></span></div>
                </div>
                <div class="row valid1">
                    <div class="col-xs-12"><a href="getClientData">Clients List</a></div>
                </div>
                <div class="row">
                    <div class="col-xs-12 buttonstyle" id="clientReg">
                        {{ Form::submit('Save') }}
                    </div>
                </div>
                <div class="row">
                    &nbsp;
                </div>    
            {{ Form::close() }}
        </div>
        <div class="footer">
            <h4>[email protected]</h4>      
        </div>
    </body>
</html>

Upvotes: 0

Views: 122

Answers (1)

Sri Harsha
Sri Harsha

Reputation: 93

I am able to figure it out myself. Issue got resolved after I added primary Key and time stamps overrides.

class client extends Eloquent{
    
    protected $table = 'client';
    protected $primaryKey = 'clientName';
    public    $timestamps = false;
    
}

Upvotes: 1

Related Questions