Penambahan Stiker Harian
This commit is contained in:
128
app/Http/Controllers/Tools/StikerExtendedController.php
Normal file
128
app/Http/Controllers/Tools/StikerExtendedController.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Tools;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TransaksiStiker;
|
||||
use App\Services\MakeStikerServices;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class StikerExtendedController extends Controller
|
||||
{
|
||||
|
||||
// protected function ;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$jenisLangganan = DB::table('jenis_langganan')->get();
|
||||
|
||||
// dd($jenisLangganan);
|
||||
return view ('tools.stiker-extend', compact('jenisLangganan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request, MakeStikerServices $makeStiker)
|
||||
{
|
||||
$request->validate([
|
||||
'jenis_langganan' => 'required|array|min:1',
|
||||
'jenis_langganan.*' => 'string',
|
||||
'tanggal_mulai' => 'required|date',
|
||||
'tanggal_selesai' => 'required|date|after:tanggal_mulai',
|
||||
]);
|
||||
|
||||
$tanggalMulai = Carbon::parse($request->tanggal_mulai);
|
||||
$tanggalSelesai = Carbon::parse($request->tanggal_selesai);
|
||||
$sticker = TransaksiStiker::select('notrans')->whereIn('jenis_langganan', $request->jenis_langganan)->get();
|
||||
// $sticker = DB::table('mergetransaksistikerdetail')->whereIn('jenis_langganan', $request->jenis_langganan)->get();
|
||||
foreach ($sticker as $row) {
|
||||
// $makeStiker->stikerExtend($sticker);
|
||||
$makeStiker->stikerExtend(
|
||||
$row,
|
||||
$tanggalMulai,
|
||||
$tanggalSelesai
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Stiker berhasil diproses'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id, Request $request)
|
||||
{
|
||||
Log::info($request->pilihannya);
|
||||
$selected = $request->pilihannya;
|
||||
$count = DB::table('transaksi_stiker')
|
||||
->whereIn('jenis_langganan', $selected)
|
||||
->get();
|
||||
|
||||
$jumlah = $count->count();
|
||||
|
||||
return response()->json([
|
||||
'jumlah' => $jumlah
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user