about summary refs log tree commit diff
path: root/laravel/app
diff options
context:
space:
mode:
Diffstat (limited to 'laravel/app')
-rw-r--r--laravel/app/Song.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/laravel/app/Song.php b/laravel/app/Song.php
index 41fbea0..f31c7ce 100644
--- a/laravel/app/Song.php
+++ b/laravel/app/Song.php
@@ -36,6 +36,17 @@ class Song extends Model
         // TODO: Validate that this is plain.
         return trim($this->key, "m");
     }
+    public function getTextAttribute($text)
+    {
+        return $text ?: file_get_contents("public/text/{$this->id}.txt");
+    }
+    public function setTextAttribute($text)
+    {
+        // Watch out, this saves immediately!
+        if ($text && file_put_contents("public/text/{$this->id}.txt", $text)) {
+            $this->attributes['text'] = null;
+        }
+    }
     public function getChordsAttribute($txt = null)
     {
         $txt = $txt ?? $this->text;