| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
-
- namespace App\Models;
-
- use Illuminate\Database\Eloquent\Casts\Attribute;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Storage;
- use Spatie\Translatable\HasTranslations;
-
- class Badge extends Model
- {
- use HasTranslations;
-
- protected $guarded = ["id"];
- public $translatable = ["title"];
- protected $appends = ["img_url_link"];
-
- protected function imgUrlLink(): Attribute
- {
- return Attribute::make(
- get: fn ($value) => is_null($this->img_url) ? null :Storage::url($this->img_url),
- );
- }
-
- public function projects()
- {
- return $this->morphedByMany(Project::class, 'badgeable');
- }
-
- }
-
-
- #!/bin/bash
- # =============================================================================
- # Fresh Export + Ready-to-use SCP command for operators
- # Run this on your backend server when someone requests today's data
- # =============================================================================
-
- set -e # Stop on any error
-
- # Config
- DB_PATH="$HOME/backend/surveys.db"
- EXPORT_DIR="$HOME/backend/exports"
- DATE=$(date +%Y%m%d) # e.g. 20251121
- TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
-
- mkdir -p "$EXPORT_DIR"
-
- MAIN_CSV="$EXPORT_DIR/surveys_${DATE}.csv"
- GB_CSV="$EXPORT_DIR/gb_surveys_${DATE}.csv"
-
- echo "=================================================="
- echo "Exporting fresh data for $DATE"
- echo "Started at: $TIMESTAMP"
- echo "=================================================="
-
- # Export main surveys
- sqlite3 "$DB_PATH" <<SQL
- .headers on
- .mode csv
- .output "$MAIN_CSV"
- SELECT
- id, name, email, phone, company, department, title,
- utm_source, utm_medium, utm_campaign,
- answer1, answer2, answer3, answer4, answer5,
- created_at, completed_at
- FROM surveys
- ORDER BY created_at DESC;
- SQL
-
- # Export GB surveys
- sqlite3 "$DB_PATH" <<SQL
- .headers on
- .mode csv
- .output "$GB_CSV"
- SELECT
- id, name, email, phone, company, department, note,
- utm_source, utm_medium, utm_campaign,
- created_at
- FROM gb_surveys
- ORDER BY created_at DESC;
- SQL
-
- # Count records
- MAIN_COUNT=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM surveys;")
- GB_COUNT=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM gb_surveys;")
-
- echo ""
- echo "SUCCESS! Files created:"
- echo " → $MAIN_CSV ($MAIN_COUNT records)"
- echo " → $GB_CSV ($GB_COUNT records)"
- echo ""
- echo "=================================================="
- echo "COPY-PASTE THIS TO DOWNLOAD:"
- echo ""
- echo "scp -i dell.pem ubuntu@43.207.13.55:~backend/exports/surveys_${DATE}.csv ~/Downloads/"
- echo "scp -i dell.pem ubuntu@43.207.13.55:~backend/exports/gb_surveys_${DATE}.csv ~/Downloads/"
- echo ""
- echo "Or download both at once:"
- echo "scp -i dell.pem ubuntu@43.207.13.55:~backend/exports/*_${DATE}.csv ~/Downloads/"
- echo ""
- echo "Finished at: $(date '+%Y-%m-%d %H:%M:%S')"
- echo "=================================================="
|