bekaskaki

bekaskaki

Member Since 5 Months Ago

indonesia

Experience Points 2,790
Experience Level 1

2,210 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 1
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Aug
4 days ago

bekaskaki started a new conversation Node_modules Folder

I run the command npm install, then the node_modules folder appears.

is it okay if I delete the node_modules folder?

02 Aug
2 weeks ago

bekaskaki started a new conversation Delete Minus Sign

i have code :

{{$transaction->net_total - $transaction->paid}}

example of results :

-1400000

can the minus sign be deleted?

30 Jul
3 weeks ago

bekaskaki left a reply on Looping Data Barcode

thank you it's work

bekaskaki started a new conversation Looping Data Barcode

i have page for barcode print by id product

like this :

https://imgur.com/RmzRLmr

i want page show 20 barcode like picture bellow

https://imgur.com/KhH3iL0

I only have 1 barcode data but I want to display as many as 20 barcodes on the page ... so, when I print a barcode, I can print as many as 20 barcodes, not just one

blade view :

<div class="row">
   <div class="col-12">
      <div class="card-box">
         <div class="header-title"> 
            <a href="#" class="btn btn-info btn-sm" onclick="printDiv('printableArea')" >
            <i class="fa fa-print"></i>
            Print
            </a>
         </div>
         <div class="panel-body" id="printableArea">
            <div class="col-md-2" style="padding: 10px; border: 1px solid #adadad;display:inline-block;line-height:16px !important; " align="center">
               <p>{{$products->name}}</p>
               <?php echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG($products->code, "c128A",1,40,array(1,1,1), true) . '"   />'; ?>
               <br>
               <small style="font-size: 8px !important;"><b>{{$products->code}}</b></small>
               <p style="line-height: 12px !important; font-size: 8px !important;">
                  <b>Price: {{$products->sale_price}} </b>
               </p>
            </div>
         </div>
      </div>
   </div>
</div>
<script>
   function printDiv(divName) {
       var printContents = document.getElementById(divName).innerHTML;
       var originalContents = document.body.innerHTML;
       document.body.innerHTML = printContents;
       window.print();
       document.body.innerHTML = originalContents;
   }
</script>

controller :

public function barcodes($id){
    $title = $this->title; 

    $products = Product::find($id);
    $vars = compact('products');

    $data = ['products' => $products];
    return view($title.'.barcodes',compact('data','products'));
}

bekaskaki started a new conversation Print Barcode Page

i have page for barcode print

like this :

https://imgur.com/FQEYGal

i want page show like this

https://imgur.com/IfC3McK

how to make page like picture above?

@extends('layouts.app')
@section('content')
<div class="row">
    <div class="col-12">
        <div class="page-title-box">
            <h4 class="page-title">Barcode</h4>
        </div>
    </div>
</div> 
<div class="row">
    <div class="col-12">
        <div class="card-box">
            <div class="header-title"> <a href="#" class="btn btn-info btn-sm" onclick="printDiv('printableArea')" >
                <i class="fa fa-print"></i>
                Print
            </a>
        </div>
        <div class="panel-body" id="printableArea">
            @foreach($products as $product)
            <div class="col-md-2" style="padding: 10px; border: 1px solid #adadad; " align="center">
                <p>{{$product->name}}</p>
                <?php echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG($product->code, "c128A",1,33,array(1,1,1), true) . '"   />'; ?>
                <br>
                <small style="font-size: 8px !important;"><b>{{$product->code}}</b></small>
                <p style="line-height: 12px !important; font-size: 8px !important;">
                    <b>Price: {{$product->sale_price}} </b>
                </p>
            </div>
            @endforeach     
        </div>
    </div>
</div>
</div>
 <script>
        function printDiv(divName) {
            var printContents = document.getElementById(divName).innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;
            window.print();
            document.body.innerHTML = originalContents;
        }
    </script>
@endsection

controller :

    public function barcode()
{
     $title = $this->title;
       $products = Product::all();
    return view($title.'.barcode',compact('products'));
}
28 Jul
3 weeks ago

bekaskaki left a reply on Alert Quantity Product In Blade View

i'm using this in blade view

@extends('layouts.app')
@section('content')

<div class="row">
<div class="col-12">
<div class="page-title-box">
<h4 class="page-title">Data Selll</h4>
</div>
</div>
</div> 
<div class="row">
<div class="col-12">
<div class="card-box">
<form method="POST" action="{{url('sell/store')}}" enctype="multipart/form-data">
{{ csrf_field() }} 
<div class="col-sm-12">
<div class="form-row">
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Sell Date</label>
<input type="text" class="form-control" placeholder="mm/dd/yyyy"  name="sell_date" id="datepicker">
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Invoice No</label>
<input type="text" class="form-control" id="ref_no" value="{{$ref_no}}" readonly>
<input type="hidden" name="invoice_no" value="{{$ref_no}}" id="invoice_no">
<span id="errMsg" class="text-danger"></span>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Customer</label>
<select class="form-control selectpicker" name="customer_id"  data-live-search="true" id="cus" required>
<option value="">Select Customer</option>
@foreach($customers as $key=>$value)
<option value="{{$key}}">{{$value}}</option>
@endforeach
</select>
</div>
<div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Product Name</label>
<input class="form-control auto" placeholder="Search Item" id="search" >
<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-2" tabindex="0" style="display: none; top: 70px; left: 10px; width: 500px;">
<li>No Item Found!</li>
</ul>
</div>
</div>
</div>

<div>
<table class="table table-bordered bg-purchase" id="purchaseInvoice">
<tbody>
<tr class="dynamicRows">
<th class="text-center">Name</th>
<th class="text-center">Unit Cost</th>
<th class="text-center">Quantity</th>
<th class="text-center">Sub Total</th>
<th class="text-center">Action</th>
</tr>
<tr class="tableInfo">
<td colspan="4" align="right"><strong>Total</strong></td>
<td align="left" colspan="2"><input type='text'  class="form-control subTotal" id="subTotal" onkeyup="sum();" readonly></td>
</tr>
<tr class="tableInfo"><td colspan="4" align="right"><strong>Paid</strong></td><td align="left" colspan="2"><input type='text'  class="form-control" id = "paidTotal" name="paid" onkeyup="sum();"></td></tr>

<tr class="tableInfo"><td colspan="4" align="right"><strong>Method</strong></td><td align="left" colspan="2">
<select name="method" id="" class="form-control">
<option value="">Select Method</option>
<option value="Cash">Cash</option>
<option value="Cash">Credit</option>
</select>
</td></tr>
<tr class="tableInfo"><td colspan="4" align="right"><strong>Due</strong></td><td align="left" colspan="2"><input type='text'  class="form-control" id = "payment_due"  readonly></td></tr>
</tbody>
</table> 
<div class="box-footer">
<button type="reset" class="btn btn-danger">Cancel</button>
<button type="submit" class="btn btn-info" id='btnSubmit'>Simpan</button>
</div>   
</div>
</form>
</div>
</div>
</div>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
function in_array(search, array)
{
for (i = 0; i < array.length; i++)
{
if(array[i] ==search )
{
return true;
}
}
return false;
}

var stack = [];
$(document).keypress(function(e) {
if(e.which == 13) {
e.preventDefault();
return false;
}
});
$( "#search" ).autocomplete({
source: function(request, response) {
$.ajax({
url: '{{url('purchase/item-search')}}',
dataType: "json",
type: "get",
data: {

search: request.term
},
success: function(data){
//Start
if(data.status_no == 1){
$("#val_item").html();
var data = data.items;
$('#ui-id-2').css('display','none');
response( $.map( data, function( item ) {
return {
id: item.id,
code: item.code,
value: item.name,
unit: item.unit,
cost_price: item.cost_price,
sale_price: item.sale_price,
initial_stock: item.initial_stock,
total_stock: item.total_stock
}
}));
}else{
$('.ui-menu-item').remove();
$('.addedLi').remove();
$("#ui-id-1").append($("<li class='addedLi'>").text(data.message));
var searchVal = $("#search").val();
if(searchVal.length > 0){
$("#ui-id-2").css('display','block');
}else{
$("#ui-id-2").css('display','none');
}
}
//end
}
})
},
select: function(event, ui) {
var e = ui.item;
if(e.id) {
if(!in_array(e.id, stack))
{
stack.push(e.id);

var taxAmount = (e.sale_price*1);

var new_row = '<tr class="nr" id="rowid'+e.id+'">'+

'<td>'+ e.value +'<input type="hidden" value=""></td><input type="hidden" name="product_id[]" value="'+e.id+'"></td>'+
'<td><input min="0"  type="text" data-id = "'+e.id+'" id="rate_id_'+e.id+'" value="'+ e.sale_price +'" class="form-control text-center unitprice" name="unit_cost_price[]" ></td>'+
'<td><input class="form-control text-center no_units" data-id="'+e.id+'" data-rate="'+ e.sale_price +'" type="text" id="qty_'+e.id+'" name="quantity[]" value="1" data-tax ="'+e.rate+'">' +
'<td><input class="form-control text-center amount" type="text" id="amount_'+e.id+'" value="'+e.sale_price+'" name="sub_total[]"  readonly></td>'+

'<td class="text-center"><button id="'+e.id+'" class="btn btn-xs btn-danger delete_item"><i class="fa fa-trash"></i></button></td>'+
'</tr>';

$(new_row).insertAfter($('table tr.dynamicRows:last'));


// Calculate subtotal
var subTotal = calculateSubTotal();
$("#subTotal").val(subTotal);



$('.tableInfo').show();

} else {
$('#qty_'+e.id).val( function(i, oldval) {
return ++oldval;
});
var q = $('#qty_'+e.id).val();
var r = $("#rate_id_"+e.id).val();

$('#amount_'+e.id).val( function(i, amount) {
var itemPrice = (q * r);
return itemPrice;
});


// Calculate subTotal
var subTotal = calculateSubTotal();
$("#subTotal").val(subTotal);
// Calculate GrandTotal

}

$(this).val('');
$('#val_item').html('');
return false;
}
},
minLength: 1,
autoFocus: true
});

$(document).ready(function() {
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});

// price calcualtion with quantity
$(document).ready(function(){
$('.tableInfo').hide();
});


$(document).on('keyup', '.no_units', function(ev){
var id = $(this).attr("data-id");
var qty = parseInt($(this).val());

var rate = $("#rate_id_"+id).val();

var price = calculatePrice(qty,rate);       

$("#amount_"+id).val(price);

// Calculate subTotal
var subTotal = calculateSubTotal();
$("#subTotal").val(subTotal);


});

// calculate amount with unit price
$(document).on('keyup', '.unitprice', function(ev){

var unitprice = parseFloat($(this).val());

var id = $(this).attr("data-id");

var qty = $("#qty_"+id).val();
//console.log(qty);
var rate = $("#rate_id_"+id).val();

var price = calculatePrice(qty,rate);
$("#amount_"+id).val(price); 

// Calculate subTotal
var subTotal = calculateSubTotal();
$("#subTotal").val(subTotal);


});

// Delete item row
$(document).ready(function(e){
$('#purchaseInvoice').on('click', '.delete_item', function() {
var v = $(this).attr("id");
stack = jQuery.grep(stack, function(value) {
return value != v;
});

$(this).closest("tr").remove();


var amountByRow = $('#amount_'+v).val();

var subTotal = calculateSubTotal();
$("#subTotal").html(subTotal);          

});
});



/**
* Calcualte Sub Total 
*@return subTotal
*/
function calculateSubTotal (){
var subTotal = 0;
$('.amount').each(function() {
subTotal += parseInt($(this).val());
});
return subTotal;
}

function calculategrandTotal (){
var grandTotal = 0;
$('.subTotal').each(function() {
grandTotal += parseInt($(this).val());
});
return grandTotal;
}
/**
* Calcualte price
*@return price
*/
function calculatePrice (qty,rate){
var price = (qty*rate);
return price;
}   

// Item not found error
$("#search").on('keyup', function(){
var searchVal = $("#search").val();
if(searchVal.length > 0){
$("#ui-id-2").css('display','block');
}else{
$("#ui-id-2").css('display','none');
}         
});

</script>


@endsection

bekaskaki started a new conversation Alert Quantity Product In Blade View

i have form input quantity, how to show alert on the form if the quantity of product out of stock?

15 Jul
1 month ago

bekaskaki left a reply on Join 3 Table By Laravel Eloquent Model

done! I have successfully displayed the name of the supplier i made a mistake at my model

model :

 public function supplier()
    {
        return $this->belongsTo('App\Supplier', 'id','supplier_id');
    }

i change to :

 public function supplier()
    {
        return $this->belongsTo('App\Supplier', 'supplier_id','id');
    }

bekaskaki left a reply on Join 3 Table By Laravel Eloquent Model

purchase from here :

class Purchase extends Model
{  
   protected $fillable = ['purchase_date','supplier_id','invoice_no','status','total','description','user_id'];

    public function supplier()
    {
        return $this->belongsTo('App\Supplier', 'id','supplier_id');
    }

     public function product()
    {
        return $this->belongsTo('App\Product');
    }

      public function purchase()
    {
        return $this->belongsTo('App\PurchaseDetail','id', 'purchase_id');
    }

i want show on blade view :

  • purchase date (from Purchase Model)
  • supplier name (from Purchase Model)// I can't get the supplier's name
  • invoice number (from Purchase Model)
  • price (from PurchaseDetail Model)

bekaskaki started a new conversation Join 3 Table By Laravel Eloquent Model

i have 3 model :

class PurchaseDetail extends Model
{
    protected $fillable = ['purchase_id','product_id','quantity','price'];
     public function purchase()
    {
        return $this->belongsTo('App\Purchase', 'purchase_id','id');
    }

    public function product()
    {
        return $this->belongsTo('App\Product', 'product_id','id');
    }
}
class Purchase extends Model
{  
   protected $fillable = ['purchase_date','supplier_id','invoice_no','status','total','description','user_id'];

    public function supplier()
    {
        return $this->belongsTo('App\Supplier', 'id','supplier_id');
    }

     public function product()
    {
        return $this->belongsTo('App\Product');
    }
      public function purchase()
    {
        return $this->belongsTo('App\PurchaseDetail','id', 'purchase_id');
    }
class Product extends Model
{
      use SoftDeletes;
      
   protected $fillable = ['name','code','category_id','subcategory_id','details','cost_price','sale_price','initial_stock','total_stock','unit','user_id'];
    
   public function purchaseh() {
        return $this->belongsTo('App\Purchase');
    }

     public function purchased() 
     {
      return $this->hasMany('App\PurchaseDetail','id','product_id');
      }

my controller :

public function history($id) 
    {
        //
        $data = PurchaseDetail::with(['purchase'])->where('product_id', $id)->orderBy('id', 'DESC')->get();
        return view ('product.history',compact('data'));
    } 

I use this but there is an error

blade view :

 <table id="datatable5" class="table table-bordered dt-responsive nowrap">
                <thead>
                    <tr>
                        <th>Purchase Date</th>
                        <th>Inovice No</th>
                        <th>Price</th>
                        <th>Supplier</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($data as $product)
                    <tr>
                        <td>{{ $product->purchase->purchase_date }}</td>
                        <td>{{ $product->purchase->invoice_no }}</td> 
                        <td>{{ $product->price }}</td>
                         <td>{{$product->purchase->supplier->name }}</td>// from model Purchase
                    </tr>
                @endforeach
            </tbody>
        </table>

is there something wrong with my model or controller? I want to display supplier name

27 Jun
1 month ago

bekaskaki left a reply on How Get Total Sum From Input Box Values Using Javascript?

@MAHAVEER - Thank you for your answer I have successfully displayed sub total values what I want is ... to display the sub-total value in the Total input box so if I add new product ... it will automatically calculate the sub total value and display it in the Total input box

bekaskaki started a new conversation How Get Total Sum From Input Box Values Using Javascript?

I am not very familiar with javascript so i think that I need some help from you guys. I want to show sub total sum of values on input box as total.

purchase_price * qty = sub_total

i need dynamically calculate total for all sub_total amounts and show in input box

view :

                <table id="purchaseInvoice" class="table table-bordered bg-purchase">
                    <thead class="">
                        <tr>
                            <th>Product</th>
                            <th>Code</th>
                            <th>Purchase Price</th>
                            <th>Unit</th>
                            <th>Quantity</th>
                            <th>Sub Total</th>
                            <th class="center">Action</th>
                        </tr>
                    </thead>
                    <tbody >
                        <tr class="dynamicRows">
                        </tr>
                    </tbody>
                    <tfoot>
                        <tr>
            <td colspan="5" style="text-align: right; font-weight: bold;">Total</td>

    <td colspan="2"><input type="text" class="form-control text-center" id="total_subtotal" name="total" ></td>
                        </tr>
                    </tfoot>
                </table>     
            </div>
        </form>
    </div>
</div>
</div>

script :

<script>
    var stack = [];
    $(document).keypress(function(e) {
        if(e.which == 13) {
            e.preventDefault();
            return false;
        }
    });
    function in_array(search, array)
    {
        for (i = 0; i < array.length; i++)
        {
            if(array[i] ==search )
            {
                return true;
            }
        }
        return false;
    }
    $( "#kd" ).autocomplete({
        source: function(request, response) {
            $.ajax({
                url: '{{url('admin/purchase/item-search')}}',
                dataType: "json",
                type: "get",
                data: {
                    cari: request.term
                },
                success: function(data){
                    var data = data.items;
                    response( $.map( data, function( item ) {
                        return {
                            id: item.id,
                            code: item.code,
                            value: item.name,
                            unit: item.unit,
                            qty: item.qty,
                            purchase_price: item.purchase_price,
                            sell_price: item.sell_price,
                        }
                    }))
                }              
            });
        },
        select: function(event, ui){
            var e=ui.item;
            if(e.id){
                if(!in_array(e.id, stack))
                {
                    stack.push(e.id);

                    var taxAmount = (e.purchase_price*1);

                    var new_row ='<tr class="nr" id="rowid'+e.id+'">'+ 
'<td><input type=hidden name=name[] value="'+e.value+'">'+e.value+'</td>'+

'<td><input type=hidden name=id[] value="'+e.id+'"><input type=hidden name=code[] value="'+e.code+'">'+e.code+'</td>'+
'<td><input id="hb'+e.id+'" type=hidden name=purchase_price[] value="'+e.purchase_price+'">'+e.purchase_price+'</td>'+
'<td><input type=hidden name=unit[] value="'+e.unit+'">'+e.unit+'</td>'+
'<td><input id="qty'+e.id+'" data-qty="'+e.id+'" class="qty" required  class="form-control" name="qty[]" value="1"  style="width:65px;"></td>'+
'<td><input data-qty="'+e.id+'" id="amount_'+e.id+'" name="sub_total[]" type="text" value="'+taxAmount+'" /></td>'+
'<td><span class="btn btn-danger js-submit-confirm delete_item" id='+e.id+'> <i class="fa fa-trash"></i></span</td>'+
                    '</tr>'
                    ;
                    $(new_row).insertAfter($('table tr.dynamicRows:last'));

                    $('#qty'+e.id).focus();
                }
                else
                {
                    $('#qty'+e.id).val( function(i, oldval) {
                        return ++oldval;
                    });
                    var q = $("#qty"+e.id).val();
                    var r = $("#hb"+e.id).val();
                    $('#amount_'+e.id).val( function(i, amount) {
                        var itemPrice = (q * r);
                        return itemPrice;
                    });
                }
            }
        }
    });
    $(document).ready(function(e){
        $('#purchaseInvoice').on('click', '.delete_item', function() {
            var v = $(this).attr("id");
            $(this).closest("tr").remove();
        });
    });
    $(document).ready(function(e){
        $('#purchaseInvoice').on('change keyup blur', '.qty', function() {
            var id = $(this).attr("data-qty");
            var qty = $("#qty"+id).val();
            var price = $("#hb"+id).val();
            $('#amount_'+id).val(qty*price);
        });
    });
</script>
18 May
3 months ago

bekaskaki left a reply on Stream_socket_sendto(): Connection Refused

check your upload max file size

13 May
3 months ago

bekaskaki left a reply on PRINT PDF, HTML To DomPdf

@EMFINANGA - done!! i have sent email.

bekaskaki left a reply on PRINT PDF, HTML To DomPdf

@EMFINANGA - i don't have TeamViewer on my pc...sent me your app files through email

bekaskaki left a reply on PRINT PDF, HTML To DomPdf

@EMFINANGA - you may have to be validate the pdf file....

i'm use this for download pdf file :

   public function cetak_invoice($id)
    {

        $title = $this->title;
        $transaksi = TransaksiKamar::with('kamar','tamu')->find($id);
        $layanan = TransaksiLayanan::where('transaksi_kamar_id',$transaksi->id)->get();
        $perusahaan = Perusahaan::all();
        $pdf = PDF::loadView('admin.'.$title.'.invoice',compact('title','transaksi','jumlah_hari','layanan','perusahaan'));
         return $pdf->stream();

    }
12 May
3 months ago

bekaskaki left a reply on Database Query

example :

$data = Room::with('roomtypes','floors')->where('status',0)->orderBy('room_number')->get();

bekaskaki left a reply on Laravel 5.8 Foreign Key

for example :

 public function store(Request $request)
    {
          $this->validate($request,[
            'test' => 'integer|min:1',
          
        ]);

       $input = $request->all();
       $input['user_id'] = Auth::user()->id;

Test::create($input);
    Alert::success('Success');
      }else{
            Alert::error('Error');

      }
    
        return Redirect::to('admin/'.$this->title);
    }

bekaskaki left a reply on How To Show Image In View When Upload?

try this :

view :

<div id="dropzone" class="box-body">
  <form method="POST" action="{{url('admin/gallery/store')}}" class="dropzone" id="gallery-dropzone" files="true" enctype="multipart/form-data">
     {{csrf_field()}}
  
  </form>
    <p>Upload File: jpg, jpeg, png</p>
  </div>

js :

<script>
          $(function () {
 Dropzone.options.galleryDropzone = {
          paramName: "gallery_img",
          maxFilesize: 20, // MB
          acceptedFiles: ".jpeg,.jpg,.png,.gif",
          };

          });
</script>

bekaskaki left a reply on Uploading A File Error

'cv' => 'file|mimes:docx|max:2048',

bekaskaki left a reply on PRINT PDF, HTML To DomPdf

@EMFINANGA - try this

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>

    <style type="text/css">
        @page {
            margin: 0px;
        }
        body {
            margin: 0px;
        }
        * {
            font-family: Verdana, Arial, sans-serif;
        }
        a {
            color: #fff;
            text-decoration: none;
        }
        #customers {
            font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
            border-collapse: collapse;
            width: 100%;
            font-size:12px;
        }
        #customers td, #customers th {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: center;
        }

        tfoot tr td {
            font-weight: bold;
            font-size:12px;
        }
        .invoice table {
            margin: 15px;
        }
        .invoice h3 {
            margin-left: 15px;
        }
        .information {
            background-color: #60A7A6;
            color: #FFF;
            font-size:12px;
        }
        .information .logo {
            margin: 5px;
        }
        .information table {
            padding: 10px;
        }
    </style>

</head>
<body>

    <div class="information">
        <table width="100%">
            <tr>
                <td align="left" style="width: 40%;">
                    <h3>name</h3>
                    <pre>
                        testttt
                        <br /><br />
                        test
                    </pre>

                </td>
                <td align="center">
                    <img src="backend/images/default.jpg" alt="Logo" width="70" class="logo"/>
                </td>
                <td align="right" style="width: 40%;">

                    <h3></h3>
                    <pre>
                        sajfkaskjfas
                    </pre>

                </td>
            </tr>

        </table>
    </div>




    <div class="invoice" style="overflow-x:auto;">
        <h4 align="center" style="font-size: 12px;">testtttt</h4>
        <table id="customers">
            <thead>
                <tr>
                    <th>Keterangan Layanan / Produk</th>
                    <th class="text-center">Harga</th>
                    <th class="text-center">Qty</th>
                    <th class="text-center">Total</th>
                </tr>
            </thead>
            <tbody>
                <tr>

                </tr>

                <tr>

                </tr>


            </tbody>

            <tfoot>
                <tr>
                    <td colspan="2"></td>
                    <td align="left">Sub Total</td>
                    <td align="left" class="gray"></td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td align="left">Grand Total</td>

                    <td align="left" class="gray"></td>
                </tr>
            </tfoot>
        </table>
    </div>

    <div class="information" style="position: absolute; bottom: 0;">
        <table width="100%">
            <tr>
                <td align="left" style="width: 50%;">
                    &copy; {{ date('Y') }} {{ config('app.url') }} - All rights reserved.
                </td>
                <td align="right" style="width: 50%;">
                    Company Slogan
                </td>
            </tr>

        </table>
    </div>
</body>
</html>
09 May
3 months ago

bekaskaki left a reply on HOW TO PERFORM SOME CALCULATION ON THE VIEW PAGE

try this :

<?php $closed_balance = $totalAmount  - $totalExpense ; ?>
<td align="left" class="gray">{{number_format($closed_balance,2)}}</td>
28 Apr
3 months ago

bekaskaki started a new conversation Query Show Data By Date And Status

db table :

 `user_id` 
  `invoice_id`
  `guest_id`
  `room_id`
  `checkin_date` 
  `checkout_date` 
  `total_price` 
  `deposit` 
  `status` //default value 0

how to query to display data by checkout_date = current date and status value 1?

i use code below but all data with 'status' values ​​0 and 1 appears :

 $guest_checkout = RoomTransaction::whereDate('checkout_date', Carbon::today())->get();

bekaskaki left a reply on If Condition Blade View

Thank you @neeonline and @snapey , I've tried two codes that you suggest, both of them works

bekaskaki left a reply on How To Use Sweet Alerts In Laravel

@LUDO1960 - i use this for delete confirmation using sweet alert

 <form class="form-horizontal" method="POST" action="{{url('admin/'.$title.'/'.$dt->id) }}" enctype="multipart/form-data">
              {{ csrf_field() }}
              <input name="_method" type="hidden" value="DELETE">
             
              <a class="js-submit-confirm">
                <i class="fa fa-trash">delete</i>
              </a>
            </form> 

script :

 $(document.body).on('click', '.js-submit-confirm', function (event) {
        event.preventDefault();
        var $form = $(this).closest('form');
        swal({
            title: "Are you sure?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes",
            closeOnConfirm: true
        },
                function () {
                    $form.submit();
                });
      });

bekaskaki left a reply on If Condition Blade View

@SNAPEY - I changed the value in the database

I have 3 values ​​in the status column

1 = used

2 = dirty

0 = available

i want show in view, Kamar with status 2, if there are no Kamar with status 2, it will display this :

@else
<div class="alert alert-warning">
<h4>Mohon Maaf</h4>
Untuk sementara, tidak ada kamar yang sedang kotor.
</div>
@endif

bekaskaki left a reply on If Condition Blade View

@NEEONLINE - I have tried the code you provided, but it still doesn't work

if and else section appear both

27 Apr
3 months ago

bekaskaki left a reply on If Condition Blade View

@PATRICKADVANCE - I have tried the code you provided, but it still doesn't work

controller :

 public function create()
    {
        $title = $this->title;
        $kamar = Kamar::with('typekamar')->where('status',2)->get();
        return view('admin.'.$title.'.create',compact('title','kamar'));
    }

full view :

@extends('admin.layouts.app')
@section('content')
<section class="content">
<div class="box">
<div class="box-body">          
<div class="row">
    
@foreach($kamar as $room)
@if ($room->status == '2')
<div class="col-sm-3">
<div class="small-box bg-yellow">
<div class="inner">
<h3>{{$room->nomor_kamar}}</h3>
<p>{{$room->typekamar->nama}}</p>
</div>
<div class="icon">
<i class="fa fa-bed"></i>
</div>
<a class="small-box-footer" href="" action="">Bersihkan</a>
</div>
</div>

@else
<div class="alert alert-warning">
<h4>Mohon Maaf</h4>
Untuk sementara, tidak ada kamar yang sedang kotor.
</div>
@endif
@endforeach

            </div>  
        </div>
    </div>
</section>
@endsection

bekaskaki left a reply on Querying Relationship Existence

@ZASTER - try this :

$sub_jobs = $sub_jobs::with('dispatches')->get();

bekaskaki started a new conversation If Condition Blade View

view :

@foreach($kamar as $room)
@if ($room->status === '2')
<div class="col-sm-3">
<div class="small-box bg-yellow">
<div class="inner">
<h3>{{$room->nomor_kamar}}</h3>
<p>{{$room->typekamar->nama}}</p>
</div>
<div class="icon">
<i class="fa fa-bed"></i>
</div>
<a class="small-box-footer" href="" action="">Bersihkan</a>
</div>
</div>

@else
<div class="alert alert-warning">
<h4>Mohon Maaf</h4>
Untuk sementara, tidak ada kamar yang sedang kotor.
</div>
@endif
@endforeach

controller :

 public function create()
    {
        $title = $this->title;
        $kamar = Kamar::with('typekamar')->where('status',2)->get();
        return view('admin.'.$title.'.create',compact('title','kamar'));
    }

I use if condition, but when I change status '0' in table, else section doesn't appear

bekaskaki left a reply on Sum Total Price

@PUNKSOLID - it's work...i change model and controller like you suggest

thank you

bekaskaki left a reply on Sum Total Price

@PUNKSOLID - i use servicecategories to display:

<div class="row">
@foreach($service as $servicess)
<div class="col-sm-3">
<a href="" class="btn btn-lg btn-block btn-primary" data-toggle="modal" data-target="#tambah-data{{$servicess->id}}">{{$servicess->kategori_name}}</a>
</div>
@endforeach

and service to display :

<div class="modal-body">
 <table class="table table-striped table-hover" id="purchaseInvoice">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Qty</th>
</tr>
</thead>
<tbody>

@foreach($services as $services)
@if ($services->service_kategori_id == $servicess->id)
<tr>
<td> <input type="hidden" name="service_id" value="{{$services->id}}">{{$services->name}}</td>

<td><input class="form-control" type="text" name="price" id="hb" value="{{$services->price}}"></td>
<td>
    <div class="row">
<div class="col-sm-4">
    <input type="text" class="form-control" name="qty" id="qty">
    <input class="form-control" type="text" name="total" id="amount_">
    </div>
    <div class="col-sm-8">
                                                                    
    </div>

bekaskaki left a reply on Sum Total Price

@PUNKSOLID - i'm trying to save total price

saving ok but displaying data wrong

$service->price = Service::find($input['price'])->price;  // from another table and will not be added to the table ServiceTransaction

show controller :

  public function show($id)
    {
        $title = $this->title ;
        $guest = RoomTransaction::with('room','guest')->find($id);
        $Service = ServiceCategori::all();
        $Services = Service::all(); //price from here
      
        return view('admin.'.$title.'.edit',compact('title','guest','Service','Services'));
    }

here is field in ServiceTransaction table :

`user_id` int(11) NOT NULL,
  `room_transaction_id` int(11) NOT NULL,
  `service_id` int(11) NOT NULL,
  `qty` int(11) NOT NULL,
  `total` int(11) NOT NULL,

'price' will not be added to the table ServiceTransaction

bekaskaki started a new conversation Sum Total Price

my controller :

public function store(Request $request)
    {
        $input = $request->all();
        $input['service_id'] = $request->service_id;
        $input['qty'] = $request->qty;
        $input['user_id'] = Auth::user()->id;
        $input['price'] = Service::find($input['price']);
        $total =  $input['price'] * $input['qty'];
        $input['total'] = $total;
        if (ServiceTransaction::create($input)){
            Alert::success('Successfully Updated', 'Success');
        }else{
             Alert::error('Something went wrong!', 'Oops...');
        }
        return Redirect::to('admin/'.$this->title);
    }

model :

class ServiceTransaction extends Model
{

    public function service(){
        return $this->hasOne('App\Service','id','service_id');
}

view :


 <div class="modal-body">
 <table class="table table-striped table-hover" id="purchaseInvoice">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Qty</th>
</tr>
</thead>
<tbody>
                        
@foreach($layanans as $services)
@if ($services->layanan_kategori_id == $service->id)
<tr>
<td> <input type="hidden" name="service_id" value="{{$services->id}}">{{$services->name}}</td>

<td><input class="form-control" type="text" name="price" id="hb" value="{{$services->price}}"></td>
<td>
    <div class="row">
    
    <div class="col-sm-4">
    <input type="text" class="form-control" name="qty" id="qty">
    <input class="form-control" type="text" name="total" id="amount_">
    </div>
    <div class="col-sm-8">
                                                                    
    </div>
    </div>
    </td>
    </tr>
    @endif
    @endforeach     
    </tbody>
    </table>

how to calculate the total price? I use $total = $input['price'] * $input['qty']; but it didn't work

10 Apr
4 months ago

bekaskaki left a reply on Can't Import Data Into Date Format

@VANDAN - if you use maatwebsite package for impor data, this is an example :

return new user([
        'UserName'           => $row['UserName'],
        'Password'           => $row['Password'],
 'date'               => \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($row['date']),
    ]);

bekaskaki left a reply on Can't Import Data Into Date Format

@VANDAN - do you use the maatwebsite package?

if you use please see :

https://github.com/Maatwebsite/Laravel-Excel/issues/1832

08 Apr
4 months ago

bekaskaki left a reply on User Email Verification

@VANDAN - thanks for reply...

my question is I have an 'active' field in the database with default value 0, how, when a user clicks on email activation the number 0 changes to number 1

bekaskaki started a new conversation User Email Verification

i have db :

  $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->string('active')->default(0);

Registercontroller :

  protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'level' => ['required', 'string', 'max:255'],
          'username' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
             'level' => $data['level'],
              'username' => $data['level'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }

     public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        return redirect()->back()->with('message', 'We sent you an activation code, Check your email and click on the link to verify');
    }

how to make, when a user clicks on email activation, the 'active' field in the database changes to 1 ?

27 Mar
4 months ago

bekaskaki started a new conversation Query Count Total Revenue

i have model :

class Appointment extends Model
{
    protected $fillable = [
      'user_id',
      'vehicle_types_id',
      'washing_plan_id',
      'status_id',
      'appointment_date',
    ];

    public function user() {
      return $this->belongsTo('App\User');
    }

    public function vehicle_type() {
      return $this->belongsTo('App\Model\Vehicle_type', 'vehicle_types_id');
    }

    public function washing_plan() {
      return $this->belongsTo('App\Model\Washing_plan');
    }

    public function status() {
      return $this->belongsTo('App\Model\Status');
    }

    


model price :

class Washing_price extends Model
{
    protected $fillable = [
      'washing_plan_id',
      'vehicle_type_id',
      'price',
      'duration',
    ];

    public function washing_plan() {
      return $this->belongsTo('App\Model\Washing_plan');
    }

    public function vehicle_type() {
      return $this->belongsTo('App\Model\Vehicle_type');
    }

}



model Plan :


class Washing_plan extends Model
{
    //
    protected $fillable = [
      'name',
    ];

    public function washing_price(){
      return $this->hasOne('App\Model\Washing_price');
    }

    public function appointment() {
      return $this->hasOne('App\Model\Appointment');
    }
}



model type :

class Vehicle_type extends Model
{
    protected $fillable = [
      'icon',
      'type',
    ];

    public function washing_price(){
      return $this->hasOne('App\Model\Washing_price');
    }

    public function appointment() {
      return $this->hasOne('App\Model\Appointment');
    }
}

I use this to display prices in the appointment view :

@foreach ($washing_prices as $washing_price)
                  @if ($washing_price->washing_plan_id == $dt->washing_plan_id && $washing_price->vehicle_type_id == $dt->vehicle_types_id)
                  ${{number_format($washing_price->price)}}
                  @endif
                @endforeach

how to calculate total revenue based on status_id?

bekaskaki left a reply on How To Add Admin User In My Application

create field role or level on your table

example :

`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sex` char(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `date_birthday` date DEFAULT NULL,
  `phone` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text COLLATE utf8mb4_unicode_ci,
  `role` char(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
23 Mar
4 months ago

bekaskaki left a reply on HowTo? Create Entity For Users And Editable In Adminpanel?

yes, you can create another controllers in admin folder. i do the same thing

22 Mar
4 months ago

bekaskaki left a reply on Undefined Variabel

@DAVIDLI - thank you!! i'm forget to define variable on array section

i change in else section :

else{

        $password = bcrypt($request->password);

        $user = User::create(['name'=>$request->name, 'email'=>$request->email, 'password'=>$password, 'sex'=>$request->sex, 'date_birthday'=>$request->date_birthday, 'username'=>$request->username, 'phone'=>$request->phone, 'role'=>$request->role]);

        $input = $request->except(['username','name', 'email', 'password', 'sex', 'date_birthday', 'phone', 'role']);

        $input['user_id'] = $user->id;


        $washing_plan = Washing_plan::findOrFail($input['washing_plan_id'])->name;
        $vehicle_company = Vehicle_company::findOrFail($input['vehicle_company_id'])->vehicle_company;
        $vehicle_modal = Vehicle_modal::findOrFail($input['vehicle_modal_id'])->vehicle_modal;
        $vehicle_type = Vehicle_type::findOrFail($input['vehicle_types_id'])->type;
        $appointment_date = $input['appointment_date'];
        $time_frame = $input['time_frame'];


        $input['appointment_date'] = date("Y/m/d", strtotime($request->appointment_date));

        $new = Appointment::create($input);

        $user = User::findOrFail($input['user_id']);

        $user->appointment()->save($new);

        if (config('mail.username') == '' && config('mail.password') == '') {
          if (Auth::attempt(['username' => $request->username, 'password' => $request->password], $request->remember_token )) {
            Alert::success('Your Appointment Has Been Booked', 'Success');
              return back();
          }
        }

        $data = array(
          'name' => $user->name,
          'email' => $user->email,
          'washing_plan' => $washing_plan,
          'vehicle_company' => $vehicle_company,
          'vehicle_modal' => $vehicle_modal,
          'vehicle_type' => $vehicle_type,
          'date' => $appointment_date,
          'time_frame' => $time_frame,
        );

it's work!!

21 Mar
4 months ago

bekaskaki started a new conversation Undefined Variabel

I was making an appointment application but got a problem. when a user logs in, the user can book, but when the user not logged in, when doing a book, there is an error. error occurs in the second part of the array data "Undefined variable: user_name"

  $data = array(
         
          'name' => $user_name,
          'email' => $user_email,
          'washing_plan' => $washing_plan,
          'vehicle_company' => $vehicle_company,
          'vehicle_modal' => $vehicle_modal,
          'vehicle_type' => $vehicle_type,
          'date' => $appointment_date,
          'time_frame' => $time_frame,
        );

controller :

 public function store(Request $request)
    {
       if (Auth::check()) {

        $input = $request->all();
      
        $user_name = User::findOrFail($input['user_id'])->name;
        $user_email = User::findOrFail($input['user_id'])->email;
        $washing_plan = Washing_plan::findOrFail($input['washing_plan_id'])->name;
        $vehicle_company = Vehicle_company::findOrFail($input['vehicle_company_id'])->vehicle_company;
        $vehicle_modal = Vehicle_modal::findOrFail($input['vehicle_modal_id'])->vehicle_modal;
        $vehicle_type = Vehicle_type::findOrFail($input['vehicle_types_id'])->type;
        $appointment_date = $input['appointment_date'];
        $time_frame = $input['time_frame'];

        $input['appointment_date'] = date("Y/m/d", strtotime($request->appointment_date));

        $new = Appointment::create($input);

        $user = User::findOrFail(Auth::user()->id);

        $user->appointment()->save($new);

        if (config('mail.username') == '' && config('mail.password') == '') {
           
          return back()->with('added', 'Your Appointment Has Been Booked');
        }

        $data = array(
         
          'name' => $user_name,
          'email' => $user_email,
          'washing_plan' => $washing_plan,
          'vehicle_company' => $vehicle_company,
          'vehicle_modal' => $vehicle_modal,
          'vehicle_type' => $vehicle_type,
          'date' => $appointment_date,
          'time_frame' => $time_frame,
        );

        Mail::send('emails.home_appointment_emails', compact('data'), function($message) use ($data){
          $message->from(config('mail.username'));
          $message->to($data['email']);
        });

        Mail::send('emails.home_appointment_emails', compact('data'), function($message) use ($data){
          $message->to(config('mail.username'));
        });
        Alert::success('Your Appointment Has Been Booked With Email', 'Success');
        return back();

      }

      else{

        $password = bcrypt($request->password);

        $user = User::create(['name'=>$request->name, 'email'=>$request->email, 'password'=>$password, 'sex'=>$request->sex, 'date_birthday'=>$request->date_birthday, 'username'=>$request->username, 'phone'=>$request->phone, 'role'=>$request->role]);

        $input = $request->except(['username','name', 'email', 'password', 'sex', 'date_birthday', 'phone', 'role']);

        $input['user_id'] = $user->id;

        $input['appointment_date'] = date("Y/m/d", strtotime($request->appointment_date));

        $new = Appointment::create($input);

        $user = User::findOrFail($input['user_id']);

        $user->appointment()->save($new);

        if (config('mail.username') == '' && config('mail.password') == '') {
          if (Auth::attempt(['username' => $request->username, 'password' => $request->password], $request->remember_token )) {
            Alert::success('Your Appointment Has Been Booked', 'Success');
              return back();
          }
        }

        $data = array(
          'name' => $user_name,
          'email' => $user_email,
          'washing_plan' => $washing_plan,
          'vehicle_company' => $vehicle_company,
          'vehicle_modal' => $vehicle_modal,
          'vehicle_type' => $vehicle_type,
          'date' => $appointment_date,
          'time_frame' => $time_frame,
        );

        Mail::send('emails.home_appointment_emails', compact('data'), function($message) use ($data){
          $message->from(config('mail.username'));
          $message->to($data['email']);
        });

        Mail::send('emails.home_appointment_emails', compact('data'), function($message) use ($data){
          $message->to(config('mail.username'));
        });

        if (Auth::attempt(['username' => $request->username, 'password' => $request->password], $request->remember_token )) {
             Alert::success('Your Appointment Has Been Booked With Email', 'Success');
            return back();
        }
      }
    }

error :

http://prntscr.com/n19o47

20 Mar
5 months ago

bekaskaki left a reply on Address In Mailbox Given [] Does Not Comply With RFC 2822, 3.6.2.

@CRONIX - thank you!!

i use :

Mail::send('emails.contact_mail', compact('data'), function($message) use ($data){
          $message->from($data['email']);
          $message->to(config('mail.username'));
          $message->subject($data['subject']);
        });

it's work

bekaskaki started a new conversation Address In Mailbox Given [] Does Not Comply With RFC 2822, 3.6.2.

my controller :

  public function send(Request $request)
    {
        $this->validate($request, [
          'name'=>'required',
          'email'=>'required|email',
          'subject'=>'required',
          'mail_message'=>'required|min:10',
        ]);

        $data = array(
          'name' => $request->name,
          'email' => $request->email,
          'subject' => $request->subject,
          'mail_message' => $request->mail_message,
        );

        Mail::send('emails.contact_mail', compact('data'), function($message) use ($data){
          $message->from($data['email']);
          $message->to(env('MAIL_USERNAME'));
          $message->subject($data['subject']);
        });
          
        Alert::success('Email Send Successfully', 'Success');
        return Redirect::to('/contact');
    }

env :

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=tls

I'm testing sending a mail to myself using gmail driver but I'm getting the following error:

Address in mailbox given [] does not comply with RFC 2822,3.6.2.

Any idea what could be wrong?