diff --git a/.env copy.example b/.env copy.example new file mode 100644 index 0000000..c3aec94 --- /dev/null +++ b/.env copy.example @@ -0,0 +1,46 @@ +APP_NAME=GrandMaster +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_URL=http://localhost/grandmaster + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=gmoji +DB_USERNAME=root +DB_PASSWORD= + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +QUEUE_CONNECTION=sync +SESSION_DRIVER=file +SESSION_LIFETIME=120 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=null +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/.env.example b/.env.example deleted file mode 100644 index 2051f85..0000000 --- a/.env.example +++ /dev/null @@ -1,46 +0,0 @@ -APP_NAME=GrandMaster -APP_ENV=local -APP_KEY= -APP_DEBUG=true -APP_URL=http://localhost/grandmaster - -LOG_CHANNEL=stack - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=grandmaster -DB_USERNAME=root -DB_PASSWORD= - -BROADCAST_DRIVER=log -CACHE_DRIVER=file -QUEUE_CONNECTION=sync -SESSION_DRIVER=file -SESSION_LIFETIME=120 - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 - -MAIL_MAILER=smtp -MAIL_HOST=smtp.mailtrap.io -MAIL_PORT=2525 -MAIL_USERNAME=null -MAIL_PASSWORD=null -MAIL_ENCRYPTION=null -MAIL_FROM_ADDRESS=null -MAIL_FROM_NAME="${APP_NAME}" - -AWS_ACCESS_KEY_ID= -AWS_SECRET_ACCESS_KEY= -AWS_DEFAULT_REGION=us-east-1 -AWS_BUCKET= - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 - -MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" -MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/app/Http/Controllers/Backend/backendpController.php b/app/Http/Controllers/Backend/backendpController.php index b643b40..f51aaf3 100644 --- a/app/Http/Controllers/Backend/backendpController.php +++ b/app/Http/Controllers/Backend/backendpController.php @@ -5,23 +5,24 @@ namespace App\Http\Controllers\Backend; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Yajra\DataTables\Facades\DataTables; -use Validator; +use Illuminate\Support\Facades\Validator; use App\Backendp; use App\Katartikel; use App\User; +use Illuminate\Support\Facades\Validator as FacadesValidator; class backendpController extends Controller { public function index() { - - return view('backend.beprog.index'); + $backendp = Backendp::all(); + return view('backend.backendp.index', compact('backendp')); } public function data(Request $request) { if ($request->ajax()) { - $backendp = Backendp::orderBy('id'); + $backendp = Backendp::orderBy('id','desc'); return Datatables::of($backendp) ->addIndexColumn() // ->addColumn('lampiran', function($backendp){ @@ -65,7 +66,7 @@ class backendpController extends Controller public function create() { - return view('backend.beprog.tambah'); + return view('backend.backendp.tambah'); } /** @@ -85,8 +86,8 @@ class backendpController extends Controller public function store(Request $request) { $validator = Validator::make($request->all(), [ - 'id' => 'required', - 'kategori_id' => 'required', + + 'judul' => 'required', 'konten' => 'required', @@ -104,6 +105,63 @@ class backendpController extends Controller return response()->json($respon); } + public function edit($id) + { + $backendp = Backendp::find($id); + + return view('backend.backendp.ubah', compact('backendp')); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $validator = Validator::make($request->all(), [ + + 'judul' => 'required', + 'konten' => 'required', + + ]); + if ($validator->fails()) { + $respon = array('status'=>false, 'pesan' => $validator->messages()); + } else { + if (backendp::find($id)->update($request->all())) { + $respon = array('status'=>true, 'pesan' => ['msg' => 'Data berhasil diubah']); + } else { + $respon = array('status'=>false, 'pesan' => ['msg' => 'Data gagal diubah']); + } + } + return response()->json($respon); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + + public function hapus($id) + { + $backendp = backendp::find($id); + return view('backend.backendp.hapus', ['backendp' => $backendp]); + } + + public function destroy($id) + { + $backendp = backendp::find($id); + if ($backendp->delete()) { + $respon = array('status'=>true, 'pesan' => ['msg' => 'Data berhasil dihapus']); + } else { + $respon = array('status'=>false, 'pesan' => ['msg' => 'Data gagal dihapus']); + } + return response()->json($respon); + } } diff --git a/app/Http/Controllers/Backend/eofficeController.php b/app/Http/Controllers/Backend/eofficeController.php index 591ecc8..c73d779 100644 --- a/app/Http/Controllers/Backend/eofficeController.php +++ b/app/Http/Controllers/Backend/eofficeController.php @@ -6,11 +6,10 @@ use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Yajra\DataTables\Facades\DataTables; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Validator; use App\Eoffice; use App\Katartikel; use App\User; -use Validator; - class eofficeController extends Controller { @@ -58,17 +57,9 @@ class eofficeController extends Controller public function create(Request $request) { - // $eoffice = Eoffice::create(); - // $katartikel_id = Katartikel::pluck('katartikel_id', 'id'); - // $eoffice = Eoffice::whith('katartikel')->where - // dd($eoffice); - - // $request->request->add(['user_id' => auth()->user()->id]); - // dd($request->all()); - //$eoffice = Eoffice::create($request->all()); - + return view('backend.eoffice.tambah'); - // [ 'eoffices' => Eoffice::with('katartikel')] + } @@ -105,8 +96,8 @@ class eofficeController extends Controller public function edit($id) { $eoffice = Eoffice::find($id); - $katartikel_id = Eoffice::pluck('id','katartikel_id'); - return view('backend.eoffice.ubah', compact('eoffice','katartikel_id')); + + return view('backend.eoffice.ubah', compact('eoffice')); } /** @@ -119,7 +110,7 @@ class eofficeController extends Controller public function update(Request $request, $id) { $validator = Validator::make($request->all(), [ - // 'katartikel_id' => 'required', + 'judul' => 'required', 'konten' => 'required', diff --git a/database/migrations/2021_10_07_144619_create_kategoris_table.php b/database/migrations/2021_10_07_144619_create_kategoris_table.php new file mode 100644 index 0000000..68d38ba --- /dev/null +++ b/database/migrations/2021_10_07_144619_create_kategoris_table.php @@ -0,0 +1,38 @@ +bigIncrements('id'); + + $table->string('kode', 90)->nulllable(); + $table->string('nama')->nulllable(); + $table->text('keterangan')->nullable(); + + $table->timestamp('created_at')->nullable(); + $table->date('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('kategoris'); + } +} diff --git a/database/migrations/2021_10_07_154619_create_kategoris_table.php b/database/migrations/2021_10_07_154619_create_kategoris_table.php deleted file mode 100644 index 68d38ba..0000000 --- a/database/migrations/2021_10_07_154619_create_kategoris_table.php +++ /dev/null @@ -1,38 +0,0 @@ -bigIncrements('id'); - - $table->string('kode', 90)->nulllable(); - $table->string('nama')->nulllable(); - $table->text('keterangan')->nullable(); - - $table->timestamp('created_at')->nullable(); - $table->date('updated_at')->nullable(); - $table->timestamp('deleted_at')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('kategoris'); - } -} diff --git a/database/migrations/2021_10_08_110118_create_formals_table.php b/database/migrations/2021_10_08_110118_create_formals_table.php index 8e0ff3c..74b5cf6 100644 --- a/database/migrations/2021_10_08_110118_create_formals_table.php +++ b/database/migrations/2021_10_08_110118_create_formals_table.php @@ -16,6 +16,7 @@ class CreateFormalsTable extends Migration Schema::create('formals', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('dokumen_id')->nullable(); + $table->foreignId('kategori_id')->references('id')->on('kategoris'); $table->string('nomor')->nullable(false); $table->string('tahun')->nullable(false); diff --git a/database/migrations/2021_10_19_091721_create_eoffices_table.php b/database/migrations/2021_10_19_091721_create_eoffices_table.php index 6ed70df..e854dce 100644 --- a/database/migrations/2021_10_19_091721_create_eoffices_table.php +++ b/database/migrations/2021_10_19_091721_create_eoffices_table.php @@ -15,7 +15,6 @@ class CreateEofficesTable extends Migration { Schema::create('eoffices', function (Blueprint $table) { $table->bigIncrements('id'); - $table->foreignId('katartikel_id')->references('kategori_id')->on('katartikels'); $table->string('judul')->nulllable(); $table->text('konten')->nullable(); $table->string('image')->nullable(); diff --git a/resources/views/backend/backendp/ajax.blade.php b/resources/views/backend/backendp/ajax.blade.php new file mode 100644 index 0000000..452b0e7 --- /dev/null +++ b/resources/views/backend/backendp/ajax.blade.php @@ -0,0 +1,76 @@ +var nextUrl=$("#url").val(); +function errorMsg(pesan){ + $(".pesan").html('
| Nama | +Username | +
|---|
+ +
+| Judul | +Konten | + +Aksi | +
|---|
+ {!! Form::label('Judul', 'Judul', array('class' => 'col-md-12 control-label')) !!} + {!! Form::text('judul', NULL, array('id' => 'judul', 'class' => 'form-control', 'placeholder' => 'Judul Artikel')) !!} +
++ {!! Form::label('Konten', 'Konten', array('class' => 'col-md-12 control-label')) !!} + {!! Form::textarea('konten', NULL, array('id' => 'konten', 'class' => 'form-control', 'rows' => '30' , 'placeholder' => 'Konten')) !!} +
+ + + {!! Form::hidden('table-list', 'datatable', array('id' => 'table-list')) !!} ++ {!! Form::label('Judul', 'Judul', array('class' => 'col-md-6 control-label')) !!} + {!! Form::text('judul', $backendp->judul, array('id' => 'judul', 'class' => 'form-control', 'placeholder' => 'Judul')) !!} +
++ {!! Form::label('Konten', 'Konten', array('class' => 'col-md-6 control-label')) !!} + {!! Form::textarea('konten', $backendp->konten, array('id' => 'konten', 'class' => 'form-control', 'placeholder' => 'Konten')) !!} +
+ + +| Nama | -Username | -
|---|
- -
-| Judul | -Konten | - -Aksi | -
|---|
- {!! Form::label('Judul', 'Judul', array('class' => 'col-md-12 control-label')) !!} - {!! Form::text('judul', NULL, array('id' => 'judul', 'class' => 'form-control', 'placeholder' => 'Judul Artikel')) !!} -
-- {!! Form::label('Konten', 'Konten', array('class' => 'col-md-12 control-label')) !!} - {!! Form::textarea('konten', NULL, array('id' => 'konten', 'class' => 'form-control', 'rows' => '30' , 'placeholder' => 'Konten')) !!} -
- - - {!! Form::hidden('table-list', 'datatable', array('id' => 'table-list')) !!} -- {!! Form::label('Kategori', 'Kategori', array('class' => 'col-md-6 control-label')) !!} - {!! Form::text('katartikel_id', $eoffice->katartikel_id, array('id' => 'katartikel_id', 'class' => 'form-control')) !!} -
-- {!! Form::label('Judul', 'Judul', array('class' => 'col-md-6 control-label')) !!} - {!! Form::text('judul', $eoffice->judul, array('id' => 'judul', 'class' => 'form-control', 'placeholder' => 'Judul')) !!} -
-- {!! Form::label('Konten', 'Konten', array('class' => 'col-md-6 control-label')) !!} - {!! Form::textarea('konten', $eoffice->konten, array('id' => 'konten', 'class' => 'form-control', 'placeholder' => 'Konten')) !!} -
- - -- {!! Form::label('Kategori', 'Kategori', array('class' => 'col-md-6 control-label')) !!} - {!! Form::text('katartikel_id', $eoffice->katartikel_id, array('id' => 'katartikel_id', 'class' => 'form-control')) !!} -
+{!! Form::label('Judul', 'Judul', array('class' => 'col-md-6 control-label')) !!} {!! Form::text('judul', $eoffice->judul, array('id' => 'judul', 'class' => 'form-control', 'placeholder' => 'Judul')) !!} diff --git a/routes/backend.php b/routes/backend.php index 0973354..387f4c1 100644 --- a/routes/backend.php +++ b/routes/backend.php @@ -1,5 +1,7 @@ config('master.url.admin')], function () { Route::get('dataon', 'pencarianController@dataOnly'); // Artikel Backend Programming - Route::get('beprog/data', 'backendpController@data')->name('beprog.data'); - Route::get('beprog/hapus/{id}', 'backendpController@hapus')->name('beprog.hapus'); - Route::get('beprog/create/{id}', 'backendpController@create')->name('beprog.create_id'); - Route::resource('beprog', 'backendpController'); + Route::get('backendp/data', 'backendpController@data')->name('backendp.data'); + Route::get('backendp/hapus/{id}', 'backendpController@hapus')->name('backendp.hapus'); + Route::get('backendp/create/{id}', 'backendpController@create')->name('backendp.create_id'); + Route::resource('backendp', 'backendpController'); // Laravel Artikel Route::get('laravel/data', 'laravelController@data')->name('laravel.data');