Anri
Anri

Reputation: 1693

eloquent does not saves an object to database

The following code gives me an error "Whoops, looks like something went wrong." in laravel 4

    $article = new Article;
    $article->name = "second article";
    $article->text = "second article desc";
    print($article->save());

Here is my model

<?php

class Article extends Eloquent {
    protected $table = 'article';

}

question: how enable debugger see inside browser to see what going wrong ?

Upvotes: 0

Views: 183

Answers (2)

Bastin Robin
Bastin Robin

Reputation: 938

I had the similar issues where i created a table without migration. And used a Model. It was fetching the table but was not able to update. When ever i called $model->save() it throws me and error. Finally found that i forgot to add created_at and updated_at columns. I think laravel had made it mandatory for all tables.

Upvotes: 0

dvabr
dvabr

Reputation: 201

In app/config/app.php set debug to true.

print outputs the value of a string, you probably want to use var_dump(), print_r() or Laravel's own dd() that dumps the passed variable and ends the script.

Upvotes: 3

Related Questions