I'm sort of new to laravel i started about 3 months ago and at minute. I'm trying to save the data you get back from twitteroath + the followers into my database but when i try to save it gets a error. Atm i'm working with laravel 5.6 and php 7.6
This is my code in the store fuction in my controller. everything in my controller up to the save works getting every date even the $twitter = new twitter works. if i dump()/dd() the $twitter at the end it will have to correct info. but once i add the $twitter->save(); its give back a error
define('CONSUMER_KEY', getenv('TWITTER_CONSUMER_KEY'));
define('CONSUMER_SECRET', getenv('TWITTER_CONSUMER_SECRET'));
define('OAUTH_CALLBACK', getenv('TWITTER_OAUTH_CALLBACK'));
$request_token = [];
$request_token['oauth_token'] = $_SESSION['oauth_token'];
$request_token['oauth_token_secret'] = $_SESSION['oauth_token_secret'];
if (isset($_REQUEST['oauth_token']) && $request_token['oauth_token'] !== $_REQUEST['oauth_token']) {
return redirect::to('dashboard.settings.index')->with('message', 'Login Failed!');
}
//This is for getting the twitteroath access_tokens, id and screenname.
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $request_token['oauth_token'], $request_token['oauth_token_secret']);
$access_token = $connection->oauth("oauth/access_token", ["oauth_verifier" => $_REQUEST['oauth_verifier']]);
$_SESSION['access_token'] = $access_token;
//This is used to get the the follower count
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$user = $connection->get('account/verify_credentials', ['tweet_mode' => 'extended', 'include_entities' => 'true']);
$twitter = new twitter;
$twitter->twitter_id = $access_token['user_id'];
$twitter->auth_token = $access_token['oauth_token'];
$twitter->auth_token_secret = $access_token['oauth_token_secret'];
$twitter->username = $access_token['screen_name'];
$twitter->followers = $user->followers_count;
$twitter->save(); //<--- this is where is gets the error
return redirect('/dashboard/settings');
And this is my model to connect to my database
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class twitter extends Model
{
public function twitter_post()
{
return $this->hasMany('App\Models\twitter_post');
}
public function ContactInformation()
{
return $this->hasOne('App\Models\ContactInformation');
}
}
In case sombody wants it here is also my table in my database.
I wonder what i am doing wrong is a very tiny mistake what i am looking right over.
EDIT
I forgot to post the error in here my bad.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into
twitters
(twitter_id
,auth_token
,auth_token_secret
,username
,followers
,updated_at
,created_at
) values (123, test, test, test, 123, 2018-11-01 10:50:18, 2018-11-01 10:50:18))
This is the error i get back.