Merge pull request #1 from williamengbjerg/patch/update-budget-title
Be able to edit names
This commit is contained in:
3 files changed
+19
-8
No files matched your search
@@ -225,17 +225,24 @@ class Projected extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateRow() {
|
public function updateRow(): void
|
||||||
|
{
|
||||||
$post = \App\Models\Post::whereHas('category', function ($query) {
|
$post = \App\Models\Post::whereHas('category', function ($query) {
|
||||||
return $query->where('user_id', \Auth::user()->id);
|
return $query->where('user_id', \Auth::user()->id);
|
||||||
})->where("id", $this->rowPostID)->first();
|
})->where("id", $this->rowPostID)->first();
|
||||||
|
|
||||||
$value = null;
|
# edit name
|
||||||
if($this->rowValue != null && trim($this->rowValue) != "" && is_numeric(trim($this->rowValue))) {
|
if ($post->name !== $this->rowName) {
|
||||||
$value = floatval($this->rowValue);
|
$post->update(['name' => $this->rowName]);
|
||||||
|
$post->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($post != null && $value !== null) {
|
$value = null;
|
||||||
|
if($this->rowValue !== null && trim($this->rowValue) !== "" && is_numeric(trim($this->rowValue))) {
|
||||||
|
$value = (float)$this->rowValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($post !== null && $value !== null) {
|
||||||
for($m=1;$m<=12;$m++) {
|
for($m=1;$m<=12;$m++) {
|
||||||
$post->setMonthValue($m, $value);
|
$post->setMonthValue($m, $value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class Post extends Model
|
|||||||
use HasFactory;
|
use HasFactory;
|
||||||
private $monthValueCache = null;
|
private $monthValueCache = null;
|
||||||
private $monthActualValueCache = null;
|
private $monthActualValueCache = null;
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
public function category() {
|
public function category() {
|
||||||
return $this->belongsTo(\App\Models\Category::class);
|
return $this->belongsTo(\App\Models\Category::class);
|
||||||
|
|||||||
@@ -192,7 +192,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="mt-1 text-center sm:mt-1">
|
<div class="mt-1 text-center sm:mt-1">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-1">
|
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-1">
|
||||||
{{$fieldName}} for ({{$fieldMonthName}})
|
{{$fieldName}} for ({{$fieldMonthName}}) <br>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="text-sm text-gray-500">
|
<p class="text-sm text-gray-500">
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5 sm:mt-6 text-center">
|
<div class="mt-5 sm:mt-6 text-center">
|
||||||
<button type="button" wire:click="updateField" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-600 text-base font-medium text-white hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:text-sm">
|
<button type="button" wire:click="updateField" class="inlin e-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-600 text-base font-medium text-white hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:text-sm">
|
||||||
Update
|
Update
|
||||||
</button>
|
</button>
|
||||||
<button type="button" wire:click="closeFieldUpdate" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:text-sm">
|
<button type="button" wire:click="closeFieldUpdate" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:text-sm">
|
||||||
@@ -223,9 +223,12 @@
|
|||||||
<div class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6">
|
<div class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6">
|
||||||
<div>
|
<div>
|
||||||
<div class="mt-1 text-center sm:mt-1">
|
<div class="mt-1 text-center sm:mt-1">
|
||||||
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-2">
|
<h3 class="text-lg leading-6 font-medium text-gray-900 mb-2" id="modal-title-2">
|
||||||
{{$rowName}}
|
{{$rowName}}
|
||||||
</h3>
|
</h3>
|
||||||
|
<label for="set-title">
|
||||||
|
<input id="set-title" name="title" type="text" wire:model.defer="rowName" class="form-input px-2 py-2 rounded-md w-10/12" />
|
||||||
|
</label>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<p class="text-sm text-gray-500">
|
<p class="text-sm text-gray-500">
|
||||||
Set value for all months (<span>{!!$rowTypeHTML!!}</span>)<br>
|
Set value for all months (<span>{!!$rowTypeHTML!!}</span>)<br>
|
||||||
|
|||||||
Reference in new issue
Block a user