Add no visual

This commit is contained in:
Ludovic CANDELLIER
2022-01-25 22:59:17 +01:00
parent bdefa235eb
commit 9f6d21ef04
6 changed files with 11 additions and 6 deletions

View File

@@ -40,6 +40,7 @@ class OffersDataTable extends DataTable
})
->editColumn('status_id', function (Offer $offer) {
return view("components.form.toggle", [
'name' => 'status_id',
'value' => $offer->status_id,
'on' => __('active'),
'off' => __('inactive'),

View File

@@ -77,7 +77,7 @@ class OfferController extends Controller
public function toggleActive(Request $request)
{
$data = Offers::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0);
$data = Offers::toggle_active($request->input('id'), ($request->input('status_id') == 'true') ? 1 : 0);
return response()->json(['error' => 0]);
}

View File

@@ -115,7 +115,7 @@ class Article extends Model implements HasMedia
public function scopeWithAvailableOffers($query)
{
return $query->whereHas('offers', function ($query) {
$query->where('status_id', 1);
$query->byStatus(1);
});
}

View File

@@ -44,7 +44,7 @@ class Offers
public static function getAll()
{
return Offer::orderBy('value', 'asc')->get();
return Offer::get();
}
public static function get($id)
@@ -77,9 +77,9 @@ class Offers
return Offer::destroy($id);
}
public static function toggle_active($id, $active)
public static function toggle_active($id, $status_id)
{
return self::update(['status_id' => $active], $id);
return self::update(['status_id' => $status_id], $id);
}
}