Saving for offers
This commit is contained in:
@@ -8,7 +8,7 @@ use App\Models\Shop\Offer;
|
|||||||
|
|
||||||
class OffersDataTable extends DataTable
|
class OffersDataTable extends DataTable
|
||||||
{
|
{
|
||||||
public $model_name = 'tariffs';
|
public $model_name = 'offers';
|
||||||
|
|
||||||
public function query(Offer $model)
|
public function query(Offer $model)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,26 +26,28 @@ class OfferController extends Controller
|
|||||||
return view('Admin.Shop.Offers.create', $data);
|
return view('Admin.Shop.Offers.create', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$data['offer'] = Offers::get($id)->toArray();
|
||||||
|
$data['articles'] = Articles::getOptions();
|
||||||
|
$data['tariffs'] = Tariffs::getOptions();
|
||||||
|
$data['variations'] = Variations::getOptions();
|
||||||
|
return view('Admin.Shop.Offers.edit', $data);
|
||||||
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
dump($request->all());
|
$data = $request->all();
|
||||||
exit;
|
$ret = Offers::store($data);
|
||||||
$ret = Offers::store($request->all());
|
|
||||||
return redirect()->route('Admin.Shop.Offers.index');
|
return redirect()->route('Admin.Shop.Offers.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$data = Offers::get($id);
|
$data['offer'] = Offers::get($id)->toArray();
|
||||||
return view('Admin.Shop.Offers.view', $data);
|
return view('Admin.Shop.Offers.view', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($id)
|
|
||||||
{
|
|
||||||
$data['customer'] = Offers::get($id)->toArray();
|
|
||||||
return view('Admin.Shop.Offers.edit', $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
return Offers::destroy($id);
|
return Offers::destroy($id);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{ Form::open(['route' => 'Admin.Shop.Offers.store', 'id' => 'offer-form', 'autocomplete' => 'off']) }}
|
{{ Form::open(['route' => 'Admin.Shop.Offers.store', 'id' => 'offer-form', 'autocomplete' => 'off']) }}
|
||||||
<input type="hidden" name="id" value="{{ $id }}">
|
<input type="hidden" name="id" value="{{ $offer['id'] }}">
|
||||||
@include('Admin.Shop.Offers.form')
|
@include('Admin.Shop.Offers.form')
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -70,36 +70,57 @@
|
|||||||
<script>
|
<script>
|
||||||
function handleArticle() {
|
function handleArticle() {
|
||||||
$('.select_article').change(function() {
|
$('.select_article').change(function() {
|
||||||
var url = '{{ route('Admin.Shop.Offers.previewArticle') }}/' + $(this).val();
|
previewArticle($(this).val());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewArticle(id) {
|
||||||
|
var url = '{{ route('Admin.Shop.Offers.previewArticle') }}/' + id;
|
||||||
$('#preview-article').load(url, function() {
|
$('#preview-article').load(url, function() {
|
||||||
initChevron();
|
initChevron();
|
||||||
});
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleVariation() {
|
function handleVariation() {
|
||||||
$('.select_variation').change(function() {
|
$('.select_variation').change(function() {
|
||||||
var url = '{{ route('Admin.Shop.Offers.previewVariation') }}/' + $(this).val();
|
previewVariation($(this).val());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewVariation(id) {
|
||||||
|
var url = '{{ route('Admin.Shop.Offers.previewVariation') }}/' + id;
|
||||||
$('#preview-variation').load(url, function() {
|
$('#preview-variation').load(url, function() {
|
||||||
initChevron();
|
initChevron();
|
||||||
});
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTariff() {
|
function handleTariff() {
|
||||||
$('.select_tariffs').change(function() {
|
$('.select_tariffs').change(function() {
|
||||||
var url = '{{ route('Admin.Shop.Offers.previewTariff') }}/' + $(this).val();
|
previewTariff($(this).val());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewTariff(id) {
|
||||||
|
var url = '{{ route('Admin.Shop.Offers.previewTariff') }}/' + id;
|
||||||
$('#preview-tariff').load(url, function() {
|
$('#preview-tariff').load(url, function() {
|
||||||
initChevron();
|
initChevron();
|
||||||
});
|
});
|
||||||
})
|
}
|
||||||
|
|
||||||
|
function initPreview() {
|
||||||
|
previewArticle("{{ $offer['article_id'] ?? null }}");
|
||||||
|
previewVariation("{{ $offer['variation_id'] ?? null }}");
|
||||||
|
previewTariff("{{ $offer['tariff_id'] ?? null }}");
|
||||||
}
|
}
|
||||||
|
|
||||||
handleArticle();
|
handleArticle();
|
||||||
handleVariation();
|
handleVariation();
|
||||||
handleTariff();
|
handleTariff();
|
||||||
initChevron();
|
initChevron();
|
||||||
initSaveForm();
|
initSaveForm('#offer-form');
|
||||||
initSelect2();
|
initSelect2();
|
||||||
|
@if ($offer['id'] ?? false)
|
||||||
|
initPreview();
|
||||||
|
@endif
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
Reference in New Issue
Block a user