Browse Source

store geo data from tweets

master
Aaron Parecki 7 years ago
parent
commit
06b84c1ec7
No known key found for this signature in database GPG Key ID: 276C2817346D6056
4 changed files with 42 additions and 1 deletions
  1. +2
    -0
      app/Http/Controllers/ImportController.php
  2. +4
    -0
      app/Http/Controllers/TwitterController.php
  3. +2
    -1
      app/Tweet.php
  4. +34
    -0
      database/migrations/2017_07_07_233528_tweet_geo.php

+ 2
- 0
app/Http/Controllers/ImportController.php View File

@ -110,6 +110,8 @@ class ImportController extends BaseController
$tweet->photo = json_encode($photos, JSON_UNESCAPED_SLASHES);
$tweet->mission_id = $mission_id;
$tweet->tweet_date = date('Y-m-d H:i:s', strtotime($data->created_at));
$tweet->geo = json_encode($data->geo);
$tweet->place = json_encode($data->place);
return $tweet;
}

+ 4
- 0
app/Http/Controllers/TwitterController.php View File

@ -57,6 +57,10 @@ class TwitterController extends BaseController
$tweet->photo = json_encode($photos, JSON_UNESCAPED_SLASHES);
$tweet->mission_id = $mission_id;
$tweet->tweet_date = date('Y-m-d H:i:s', strtotime($data['created_at']));
if(isset($data['geo']))
$tweet->geo = json_encode($data['geo']);
if(isset($data['place']))
$tweet->place = json_encode($data['place']);
$tweet->save();
if($tweet->mission_id && $tweet->team_id) {

+ 2
- 1
app/Tweet.php View File

@ -13,7 +13,8 @@ class Tweet extends Model
'm1_transit_line_id', 'm1_non_trimet',
'm2_transit_center_id', 'm2_with_other_team',
'm3_complete', 'm4_complete', 'm5_complete', 'm5_tip',
'm6_complete', 'm7_document_id'
'm6_complete', 'm7_document_id',
'geo', 'place'
];
public function team() {

+ 34
- 0
database/migrations/2017_07_07_233528_tweet_geo.php View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class TweetGeo extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tweets', function (Blueprint $table) {
$table->text('geo')->nullable();
$table->text('place')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tweets', function (Blueprint $table) {
$table->dropColumn('geo');
$table->dropColumn('place');
});
}
}

Loading…
Cancel
Save