Commit 85beb6f8 by Aan Choesni Herlingga

draft master autopost

parent 02efc466
<?php
namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class AutopostController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* 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)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* 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)
{
//
}
}
<?php
namespace App\Models\Webprofile;
use App\Http\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Model;
class Autopost extends Model
{
use UuidTrait;
public $incrementing = false;
protected $table = 'swp_autopost';
protected $guarded = [];
}
<?php
namespace App\Repositories\Webprofile;
use App\Models\Webprofile\Autopost;
use App\Repositories\Repository;
class AutopostRepository extends Repository
{
protected $model;
public function __construct(Autopost $model)
{
$this->model = $model;
}
public function get($with = null, $name = null, $orderBy = null)
{
return $this->model
->when($with, function ($query) use ($with) {
return $query->with($with);
})
->when($name, function ($query) use ($name) {
return $query->where('name', 'ilike', '%'.$name.'%');
})
->when($orderBy, function ($query) use ($orderBy) {
return $query->orderBy($orderBy[0], $orderBy[1]);
})
->get();
}
public function datatable($data)
{
return DataTables::of($data)
->addIndexColumn()
->addColumn('action', function ($row) {
$btn = '<a href="'.url('/webprofile/autopost/'.$row->id.'/edit').'" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="Edit" class="edit btn btn-warning btn-round btn-sm edit">Edit</a>';
$btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip" data-id="'.$row->id.'" data-original-title="Delete" class="btn btn-danger btn-round btn-sm delete">Delete</a>';
$btn = $btn.'<br>';
return $btn;
})
->addColumn('status', function ($row) {
if ($row->is_active == true) {
$str = '<div style="color: green;"><i class="fa fa-check"></i></div>';
} else {
$str = '<div style="color: red;"><i class="fa fa-times"></i></div>';
}
return $str;
})
->rawColumns(['action', 'status'])
->make(true);
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAutopostTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('swp_autopost', function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->string('name');
$table->string('type');
$table->string('key_1');
$table->string('key_2');
$table->string('key_3');
$table->string('key_4');
$table->string('key_5');
$table->string('key_6');
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('swp_autopost');
}
}
$(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var table = $('.data-table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: url,
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex' },
{ data: 'name', name: 'name' },
{ data: 'status', name: 'status' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
],
columnDefs: [
{ className: 'text-center', targets: [0, 3] },
{ className: 'text-left', targets: [1, 2] },
],
});
$("body").on("click", ".delete", function (e) {
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Apakah Anda Yakin?",
text: "Anda akan menghapus data ini!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal.close();
setTimeout(function () {
$.ajax({
dataType: 'json',
type: 'DELETE',
url: url + '/' + id,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
}).done(function (data) {
table.draw();
swal({
title: "Data berhasil dihapus!",
type: "success",
timer: "3000"
});
});
}, 1000); // 1 second delay
}
else {
swal("Dibatalkan", "Data batal dihapus", "error");
}
}
);
});
});
$(function () {
//iCheck for checkbox and radio inputs
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass: 'iradio_minimal-blue'
});
});
function printErrorMsg(msg) {
$(".print-error-msg").find("ul").html('');
$(".print-error-msg").css('display', 'block');
$.each(msg, function (key, value) {
$(".print-error-msg").find("ul").append('<li>' + value + '</li>');
});
}
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">Dashboard</a></li>
<li class="active">Add API</li>
@stop
@section('content')
{!! Form::open(array('url' => route('autopost.store'), 'method' => 'POST', 'id' => 'autopost', 'class' => 'form-horizontal')) !!}
{!! csrf_field() !!}
<!-- page start-->
<div class="row">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>Add</strong> API</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group @if ($errors->has('name')) has-error @endif">
<label class="col-md-2 control-label">Name</label>
<div class="col-md-10">
{{ Form::text('name', old('name'), array('class' => 'form-control')) }}
@if ($errors->has('name'))
<label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-footer">
<a href="{{URL::to('webprofile/autopost')}}" class="btn btn-default pull-right">Batal</a>
<button class="btn btn-info pull-right">Simpan</button>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
<!-- page end-->
@stop
@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
@stop
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">Dashboard</a></li>
<li class="active">Edit Autopost</li>
@stop
@section('content')
{!! Form::model($data, ['route' => ['autopost.update', $data->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!}
{!! csrf_field() !!}
<!-- page start-->
<div class="row">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>Edit</strong> Autopost</h3>
</div>
<div class="panel-body">
<div class="row">
<div style="padding: 10px 10px 10px 10px; font-weight: bold; font-size: 14pt;">
Bahasa Indonesia
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('name')) has-error @endif">
<label class="col-md-2 control-label">Name</label>
<div class="col-md-10">
{{ Form::text('name', old('name'), array('class' => 'form-control')) }}
@if ($errors->has('name'))
<label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-footer">
<a href="{{URL::to('webprofile/category')}}" class="btn btn-default pull-right">Batal</a>
<button class="btn btn-info pull-right">Simpan</button>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
<!-- page end-->
@stop
@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
@stop
@extends('webprofile.backend.layouts.master')
@section('assets')
<link rel="stylesheet" href="{!! asset('backend/js/datatables.net-bs/css/dataTables.bootstrap.min.css') !!}">
<meta name="csrf-token" content="{{ csrf_token() }}">
@endsection
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.category')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
<div class="col-lg-12">
<!-- START DEFAULT DATATABLE -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3>
<a class="btn btn-info" href="{{URL::to('webprofile/category/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div class="col-sm-12" style="overflow-x: auto">
<table class="table table-hover data-table" width="100%">
<thead>
<tr>
<th width="7%">@lang('label.number')</th>
<th width="63%">@lang('label.name')</th>
<th width="10%">@lang('label.status')</th>
<th align="center" width="15%">@lang('label.action')</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<!-- END DEFAULT DATATABLE -->
</div>
</div>
<!-- page end-->
@stop
@section('script')
<!-- DataTables -->
<script src="{!!asset('backend/js/datatables.net/js/jquery.dataTables.min.js') !!}"></script>
<script src="{!!asset('backend/js/datatables.net-bs/js/dataTables.bootstrap.min.js') !!}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/dataTables.buttons.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.bootstrap4.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.colVis.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.html5.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.print.min.js') }}"></script>
<script>
var url = "{{ route('category.index') }}";
</script>
{{ Html::script('js/master/category.js') }}
@stop
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment