diff --git a/app/Http/Livewire/Projected.php b/app/Http/Livewire/Projected.php index b1a92cf..bc95d48 100644 --- a/app/Http/Livewire/Projected.php +++ b/app/Http/Livewire/Projected.php @@ -217,10 +217,10 @@ class Projected extends Component })->where("id", $id)->first(); if($post) { - $this->rowPostID = $post->id; - $this->rowName = $post->name; - $this->rowTypeHTML = "is_expense ? "col-neg" : "col-pos")."\">".($post->is_expense ? "expense" : "income").""; - $this->modalRowUpdate = true; + $this->rowPostID = $post->id; + $this->rowName = $post->name; + $this->rowTypeHTML = "is_expense ? "col-neg" : "col-pos")."\">".($post->is_expense ? "expense" : "income").""; + $this->modalRowUpdate = true; $this->emit("focusField", "rowValue"); } } @@ -230,6 +230,11 @@ class Projected extends Component return $query->where('user_id', \Auth::user()->id); })->where("id", $this->rowPostID)->first(); + if ($post->name !== $this->rowName) { + $post->update(['name' => $this->rowName]); + $post->save(); + } + $value = null; if($this->rowValue != null && trim($this->rowValue) != "" && is_numeric(trim($this->rowValue))) { $value = floatval($this->rowValue); diff --git a/app/Models/Post.php b/app/Models/Post.php index 49d6a8c..4f9f0ba 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -10,6 +10,7 @@ class Post extends Model use HasFactory; private $monthValueCache = null; private $monthActualValueCache = null; + protected $guarded = []; public function category() { return $this->belongsTo(\App\Models\Category::class); diff --git a/resources/views/livewire/projected.blade.php b/resources/views/livewire/projected.blade.php index 49c412b..b56416a 100644 --- a/resources/views/livewire/projected.blade.php +++ b/resources/views/livewire/projected.blade.php @@ -185,14 +185,14 @@