Skip to content

Commit

Permalink
Merge pull request #44 from Woody174/devil
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to authored Dec 11, 2022
2 parents a0cbc04 + a24cbd9 commit 5eb79c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Http/Controllers/MoonShineDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Storage;
Expand Down Expand Up @@ -41,11 +42,13 @@ public function autoUpdate(Request $request): array
{
$class = $request->get('model');
$model = new $class();
if (in_array(SoftDeletes::class, class_uses_recursive($model), true)) {
$model = $model->withTrashed();
}
$item = $model->findOrFail($request->get('key'));

$item->update([
$request->get('field') => $request->boolean('value')
]);
$item->{$request->get('field')} = $request->boolean('value');
$item->save();

return $item->toArray();
}
Expand Down

0 comments on commit 5eb79c8

Please sign in to comment.