feat: airing proof theme

This commit is contained in:
myuqinurrohman 2025-02-28 07:50:12 +07:00
parent fc2f5289f4
commit 5d28f9c982
13 changed files with 529 additions and 1 deletions

View File

@ -0,0 +1,84 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Http\Requests\AiringProofThemeRequest;
use App\Models\AiringProofTheme;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
class AiringProofThemeController extends Controller
{
public function index(){
return view('dashboard.airing-proof-themes.index', [
'title' => "Tema Bukti Tayang"
]);
}
public function create(){
return view('dashboard.airing-proof-themes.create', [
'title' => "Tambah Tema Bukti Tayang"
]);
}
public function store(AiringProofThemeRequest $request){
$validatedData = $request->validated();
$validatedData['slug'] = Str::slug($validatedData['name']. ' '. $validatedData['year']);
$validatedData['enhancer_id'] = Auth::id();
$createdTheme = AiringProofTheme::create($validatedData);
if($createdTheme){
return redirect()->back()->with('success-status', 'Berhasil menambahkan tema bukti tayang.');
}else{
return redirect()->back()->with('failed-status', 'Gagal menambahkan tema bukti tayang.');
}
}
public function edit($id){
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
return view('dashboard.airing-proof-themes.edit', [
'title' => "Ubah Tema Bukti Tayang",
'airingProofTheme' => $airingProofTheme
]);
}
public function update(AiringProofThemeRequest $request, $id){
$validatedData = $request->validated();
$validatedData['slug'] = Str::slug($validatedData['name']. ' '. $validatedData['year']);
$validatedData['enhancer_id'] = Auth::id();
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
$updatedAiringProofTheme = $airingProofTheme->update($validatedData);
if($updatedAiringProofTheme){
return redirect()->back()->with('success-status', 'Berhasil mengubah tema bukti tayang.');
}else{
return redirect()->back()->with('failed-status', 'Gagal mengubah tema bukti tayang.');
}
}
public function show($id){
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
return view('dashboard.airing-proof-themes.show', [
'title' => "Detail Tema Bukti Tayang",
'airingProofTheme' => $airingProofTheme
]);
}
public function destroy($id){
try {
$airingProofTheme = AiringProofTheme::findOrFail(decrypt_id($id));
$airingProofTheme->delete();
return response()->json(['message' => 'Berhasil menghapus tema bukti tayang.']);
} catch (\Exception $e) {
return response()->json(['message' => 'Gagal menghapus tema bukti tayang.'], 500);
}
}
}

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\AiringProofTheme;
use App\Models\Classification;
use App\Models\GovernmentAgency;
use App\Models\News;
@ -246,4 +247,50 @@ public function news(Request $request){
return response()->json(['error' => 'Unauthorized'], 401);
}
public function airingProofTheme(Request $request){
if ($request->ajax()) {
$data = AiringProofTheme::all();
return DataTables::of($data)
->addIndexColumn()
->addColumn('action', function ($data) {
$showUrl = route('dashboard.airing.proof.themes.show', ['id' => encrypt_id($data->id)]);
$editUrl = route('dashboard.airing.proof.themes.edit', ['id' => encrypt_id($data->id)]);
$deleteUrl = route('dashboard.airing.proof.themes.destroy', ['id' => encrypt_id($data->id)]);
$dropdown = '<div class="dropdown" style="display:flex; justify-content:center;">
<a class="dropdown-toggle btn btn-icon btn-light" data-bs-toggle="dropdown"><em class="icon ni ni-more-v"></em></a>
<div class="dropdown-menu dropdown-menu-end">
<ul class="link-list-opt">
<li><a href="'.$showUrl.'"><em class="icon ni ni-eye"></em><span>Detail</span></a></li>';
if (is_role([1])) {
$dropdown .= '<li><a href="'.$editUrl.'"><em class="icon ni ni-edit"></em><span>Ubah</span></a></li>';
}
if (is_role([1])) {
$dropdown .= '<li><a href="javascript:void(0);" onclick="deleteItem(\''.$deleteUrl.'\', \'Apakah Anda yakin ingin menghapus tema '.$data->name.'? Item ini akan dihapus secara permanen!\')"><em class="icon ni ni-trash"></em><span>Hapus</span></a></li>';
}
$dropdown .= '</ul>
</div>
</div>';
return $dropdown;
})
->rawColumns(['action'])
->make(true);
}
return response()->json(['error' => 'Unauthorized'], 401);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class AiringProofThemeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Auth::check() && is_role(['1']);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'max:100'],
'year' => ['required', 'max:5'],
'description' => ['nullable'],
];
}
public function messages(): array
{
return [
'name.required' => 'Nama harus diisi.',
'name.max' => 'Nama tidak boleh lebih dari 100 karakter.',
'year.required' => 'Tahun harus diisi.',
'year.max' => 'Tahun tidak boleh lebih dari 5 karakter.',
'description.nullable' => 'Deskripsi bersifat opsional.',
];
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class AiringProofTheme extends Model
{
protected $table = 'airing_proof_themes';
protected $fillable = [
'name',
'slug',
'year',
'description',
'enhancer_id'
];
}

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('airing_proof_themes', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug');
$table->string('year');
$table->text('description')->nullable();
$table->unsignedBigInteger('enhancer_id');
$table->foreign('enhancer_id')->references('id')->on('users');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('airing_proof_themes');
}
};

View File

@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class AiringProofThemeSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -0,0 +1,65 @@
@include('partials.dashboard.head')
@include('partials.dashboard.sidebar', ['page' => 'airing_proof_themes'])
@include('partials.dashboard.header')
<!-- content @s -->
<div class="nk-content ">
<div class="container-fluid">
<div class="nk-content-inner">
<div class="nk-content-body">
<div class="nk-block nk-block-lg">
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="card-head">
<h5 class="card-title">{{$title}}</h5>
</div>
<form action="{{route('dashboard.airing.proof.themes.store')}}" method="post">
@csrf
<div class="row g-4">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="name">Nama<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('name') border-danger @enderror" id="name" name="name" placeholder="Masukan nama tema" value="{{old('name')}}">
</div>
@error('name')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="year">Tahun<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('year') border-danger @enderror" id="year" name="year" placeholder="Masukan tahun" value="{{old('year')}}">
</div>
@error('year')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="phone-no-1">Deskripsi</label>
<div class="form-control-wrap">
<textarea class="tinymce-basic form-control" name="description">{!!old('description')!!}</textarea>
</div>
</div>
</div>
<div class="col-12">
<hr>
<div class="form-group d-flex justify-content-end">
<a href="{{route('dashboard.airing.proof.themes.index')}}" class="btn btn-white btn-dim btn-outline-light mx-2"><span>Kembali</span></a>
<button type="submit" class="btn btn-md btn-primary">Tambahkan</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content @e -->
@include('partials.dashboard.footer', ['rich_editor' => true])

View File

@ -0,0 +1,66 @@
@include('partials.dashboard.head')
@include('partials.dashboard.sidebar', ['page' => 'airing_proof_themes'])
@include('partials.dashboard.header')
<!-- content @s -->
<div class="nk-content ">
<div class="container-fluid">
<div class="nk-content-inner">
<div class="nk-content-body">
<div class="nk-block nk-block-lg">
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="card-head">
<h5 class="card-title">{{$title}}</h5>
</div>
<form action="{{route('dashboard.airing.proof.themes.update', ['id' => encrypt_id($airingProofTheme->id)])}}" method="post">
@csrf
@method('put')
<div class="row g-4">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="name">Nama<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('name') border-danger @enderror" id="name" name="name" placeholder="Masukan nama tema" value="{{$airingProofTheme->name}}">
</div>
@error('name')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="year">Tahun<span class="required-input">*</span></label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('year') border-danger @enderror" id="year" name="year" placeholder="Masukan tahun" value="{{$airingProofTheme->year}}">
</div>
@error('year')
<span class="validation-error">{{$message}}</span>
@enderror
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="phone-no-1">Deskripsi</label>
<div class="form-control-wrap">
<textarea class="tinymce-basic form-control" name="description">{!!$airingProofTheme->description!!}</textarea>
</div>
</div>
</div>
<div class="col-12">
<hr>
<div class="form-group d-flex justify-content-end">
<a href="{{route('dashboard.airing.proof.themes.index')}}" class="btn btn-white btn-dim btn-outline-light mx-2"><span>Kembali</span></a>
<button type="submit" class="btn btn-md btn-primary">Simpan</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content @e -->
@include('partials.dashboard.footer', ['rich_editor' => true])

View File

@ -0,0 +1,60 @@
@include('partials.dashboard.head')
@include('partials.dashboard.sidebar', ['page' => 'airing_proof_themes'])
@include('partials.dashboard.header')
<!-- content @s -->
<div class="nk-content ">
<div class="container-fluid">
<div class="nk-content-inner">
<div class="nk-content-body">
<div class="nk-block-head nk-block-head-sm">
<div class="nk-block-between">
<div class="nk-block-head-content">
<h3 class="nk-block-title page-title">{{$title}}</h3>
</div><!-- .nk-block-head-content -->
<div class="nk-block-head-content">
<div class="toggle-wrap nk-block-tools-toggle">
<a href="#" class="btn btn-icon btn-trigger toggle-expand me-n1" data-target="pageMenu"><em class="icon ni ni-more-v"></em></a>
<div class="toggle-expand-content" data-content="pageMenu">
<ul class="nk-block-tools g-3">
{{-- <li>
<div class="drodown">
<a href="#" class="dropdown-toggle btn btn-white btn-dim btn-outline-light" data-bs-toggle="dropdown"><em class="d-none d-sm-inline icon ni ni-calender-date"></em><span><span class="d-none d-md-inline">Last</span> 30 Days</span><em class="dd-indc icon ni ni-chevron-right"></em></a>
<div class="dropdown-menu dropdown-menu-end">
<ul class="link-list-opt no-bdr">
<li><a href="#"><span>Last 30 Days</span></a></li>
<li><a href="#"><span>Last 6 Months</span></a></li>
<li><a href="#"><span>Last 1 Years</span></a></li>
</ul>
</div>
</div>
</li> --}}
<li class="nk-block-tools-opt"><a href="{{route('dashboard.airing.proof.themes.create')}}" class="btn btn-primary"><em class="icon ni ni-plus"></em><span>Tambah</span></a></li>
</ul>
</div>
</div>
</div><!-- .nk-block-head-content -->
</div><!-- .nk-block-between -->
</div><!-- .nk-block-head -->
<div class="nk-block nk-block-lg">
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="table-responsive">
<table class="table table-striped table-bordered nowrap" id="airingProofThemesTable" border="1">
<thead>
<tr>
<th style="width: 10% !important;">No</th>
<th>Nama</th>
<th style="width: 10% !important;"></th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content @e -->
@include('partials.dashboard.footer' ,['datatable' => 'airing_proof_theme'])

View File

@ -0,0 +1,59 @@
@include('partials.dashboard.head')
@include('partials.dashboard.sidebar', ['page' => 'airing_proof_themes'])
@include('partials.dashboard.header')
<!-- content @s -->
<div class="nk-content ">
<div class="container-fluid">
<div class="nk-content-inner">
<div class="nk-content-body">
<div class="nk-block nk-block-lg">
<div class="card card-bordered card-preview">
<div class="card-inner">
<div class="card-head">
<h5 class="card-title">{{$title}}</h5>
</div>
<form action="#" method="post">
@csrf
<div class="row g-4">
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="name">Nama</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('name') border-danger @enderror" id="name" name="name" placeholder="Masukan nama tema" value="{{$airingProofTheme->name}}" readonly>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label class="form-label" for="year">Tahun</label>
<div class="form-control-wrap">
<input type="text" class="form-control @error('year') border-danger @enderror" id="year" name="year" placeholder="Masukan tahun" value="{{$airingProofTheme->year}}" readonly>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<label class="form-label" for="phone-no-1">Deskripsi</label>
<div class="form-control-wrap">
<div class="description-content">{!! $airingProofTheme->description !!}</div>
</div>
</div>
</div>
<div class="col-12">
<hr>
<div class="form-group d-flex justify-content-end">
<a href="{{route('dashboard.airing.proof.themes.index')}}" class="btn btn-white btn-dim btn-outline-light mx-2"><span>Kembali</span></a>
<a href="{{route('dashboard.airing.proof.themes.edit', ['id' => encrypt_id($airingProofTheme->id)])}}" class="btn btn-warning"><span>Ubah</span></a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- content @e -->
@include('partials.dashboard.footer', ['rich_editor' => true])

View File

@ -115,3 +115,25 @@
});
</script>
@endif
@if ($datatable === 'airing_proof_theme')
<script>
$(document).ready(function() {
$('#airingProofThemesTable').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('dashboard.airing.proof.themes.data') }}',
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false },
{ data: 'name', name: 'name' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
{ data: 'id', name: 'id', orderable: true, searchable: false, visible: false },
],
language: datatableLanguage,
autoWidth: false,
order: [[1, 'desc']],
lengthMenu: [[10, 25, 50, 100, -1], ['Tampilkan 10 data', 'Tampilkan 25 data', 'Tampilkan 50 data', 'Tampilkan 100 data', 'Tampilkan semua']]
});
});
</script>
@endif

View File

@ -79,7 +79,7 @@
</a>
</li><!-- .nk-menu-item -->
<li class="nk-menu-item">
<a href="javascript:void(0);" class="nk-menu-link">
<a href="{{route('dashboard.airing.proof.themes.index')}}" class="nk-menu-link {{$page === 'airing_proof_themes' ? 'active-page' : ''}}">
<span class="nk-menu-icon"><em class="icon ni ni-puzzle"></em></span>
<span class="nk-menu-text">Tema</span>
</a>

View File

@ -1,6 +1,7 @@
<?php
use App\Http\Controllers\AuthController;
use App\Http\Controllers\Dashboard\AiringProofThemeController;
use App\Http\Controllers\Dashboard\ClassificationController;
use App\Http\Controllers\Dashboard\DatatableController;
use App\Http\Controllers\Dashboard\GovernmentAgencyController;
@ -90,6 +91,20 @@
Route::get('/data', [DatatableController::class, 'news'])->name('data');
});
Route::prefix('airing-proof-themes')->name('airing.proof.themes.')->group(function(){
Route::controller(AiringProofThemeController::class)->group(function(){
Route::get('/', 'index')->name('index');
Route::get('/create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('/{id}/show', 'show')->name('show');
Route::get('/{id}/edit', 'edit')->name('edit');
Route::put('/{id}', 'update')->name('update');
Route::delete('/{id}', 'destroy')->name('destroy');
});
Route::get('/data', [DatatableController::class, 'airingProofTheme'])->name('data');
});
Route::prefix('settings')->name('settings.')->group(function(){
Route::controller(SettingController::class)->group(function(){
Route::get('/', 'index')->name('index');