obink

Member Since 6 Months Ago

Experience Points
2,690
Total
Experience

2,310 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
2,690 XP
Apr
12
5 days ago
Activity icon

Replied to Laravel Array If Condition With Another Variable

I'm sorry for late replay, I updated the question. please help.. @neilstee

Activity icon

Replied to Laravel Array If Condition With Another Variable

I'm sorry for late replay, I updated the question. please help.. @corvs

Apr
10
1 week ago
Activity icon

Started a new Conversation Laravel Array If Condition With Another Variable

I don't know how to put the title to be well enough.

I have a condition of some text inputs to be less than some variable from the database

$products = $request->input('products', []);
$quantities = $request->input('quantities', []);
$pricing = $request->input('invoicePrices', []);

$theProduct = DB::table('products')->whereIn('id', $products)->select('stock')->get();

So, I have to do some validation which saying.. Input Quantities, cannot be greater than theProduct Stock

I'm not so great with Array. I'm trying something silly which is not good and not right.

if(in_array($quantities, '<', $theProduct)){
    return 'helo';
}

How to do this? please help.

============================================================================ UPDATED QUESTION

I apologize for my rush typed question. and I seem to ignore people who tried to help me, I was consumed by time trying to get this done.

the main objective is: I need to validate the user's input, I have 1 eloquent named invoice it has many products in a single purchasing order, it sometimes has return single product / multiple products.

so the validation must be.. invoice product quantity cannot be less than product, and if there is a returned product. The peculiar product quantity cannot be less than the stock and returned product quantity.

$products = $request->input('products', []); // this is the input products the value is the product_id
$quantities = $request->input('quantities', []); // this is the input invoice products quantity
$pricing = $request->input('invoicePrices', []); // this is the input invoice products price

$stockProduct = DB::table('products')->whereIn('id', $products)->select('stock')->get();
$arrayStock = $stockProduct->pluck('stock')->toArray(); // I find the product's stock from input product_id and put it in to an array.

$getReturn = DB::table('product_return_invoice')->where('invoice_id', $invoice->id)->whereIn('product_id', $products)->select('product_id', 'quantity')->get();
$arrayReturn = $getReturn->pluck('quantity','product_id')->toArray(); // I find the invoice product's return from input return invoice database and put it in to an array.

I hope I described it clear enough for every variable needed. and the next step is I tried to examine input quantity if the input is less than stock.

for ($i=0; $i <count($quantities) ; $i++) {
                $stockRes = $arrayStock[$i] - $quantities[$i];
                $ares[] = $stockRes;
            }

$theCollection = array_filter($ares, function($value){
                return $value < 0;
            });

So I hope the array stock subtract with input quantities is more than 0 which is there is enough stock if we changed the input value. and I put in the if condition.

if(count($theCollection) == 0){
		Updating the invoice
}
else{
		send back to edit page, with flash there is something error with stock and quantity
}

That was as far I can go. but about the returned invoice Product, I got lost... I tried to do something with the $arrayReturn. I'm changing the key and value of this array with id and quantity of the returned product

foreach ($quantities as $oriKey => $value) {
    $changedKey[$products[$oriKey]] = $value;
}

dd($arrayStock, $quantities, $arrayReturn, $ares, $products);

and getting the dump response like....

now now... I need to make a validation like,

if there is a returned product from this invoice, the user cannot update the input less than the invoice returned product quantity && cannot be less than the product stock.

I came up with the idea of input quantities - returned invoice product cannot be less than 0. But IDK how to subtract it nicely.

I want to subtract the input with the returned product quantity, and the result of subtraction is the key for validation before validating the stock. the scratch would be like:

$products =
  0 => 7
  1 => 9
  2 => 6
  3 => 8

$quantities = 
  0 => "40"
  1 => "40"
  2 => "40"
  3 => "40"


// the product id which has return is
$return =
0 => 9
1 => 8

//the return quantity of those respective product id is
$return quantity = 
 0 => 20
 1 => 20

sorry for the late update.. once again, I tried my best to do this so I hope I don't need to trouble you guys. But it seem I need more help. please help. Thanks in advance.

Mar
27
3 weeks ago
Activity icon

Replied to Array_merge(): Expected Parameter 2 To Be An Array, String Given

right right, my careless. I immediately change it into return redirect(route('order.show', $data['order_id']));

ty @viorel

Activity icon

Started a new Conversation Array_merge(): Expected Parameter 2 To Be An Array, String Given

Got this Error and IDK what happened. It's just a normal laravel::create

 public function store(Request $request)
    {
        $detail  = DB::table('order_product')
                    ->where('order_id', $request->order_id)
                    ->where('product_id', $request->product_id)
                    ->get();

        $data = $request->validate([
            'order_id' => 'required',
            'product_id' => 'required',
            'reason' => '',
            'quantity' => 'required|numeric|max:'.$detail->sum('quantity'),
            'orderPrice' => 'required|numeric',
        ]);
        $subtotal = $data['quantity']*$data['orderPrice'];

        ReturnOrder::create([
            'order_id' => $data['order_id'],
            'product_id' => $data['product_id'],
            'reason' => $data['reason'],
            'quantity' => $data['quantity'],
            'orderPrice' => $data['orderPrice'],
            'subtotal' => $subtotal,
        ]);

        return view('orders.show', $request->order_id);
}

please help

Mar
25
3 weeks ago
Activity icon

Started a new Conversation Prevent The Same Option Value In Form::select

I have a dynamic table which can add and delete row as I will, and inside of the table have a select-option input.

<table class="table dynatable w-50" border="1 thick black" id="products_table">
<thead>
    <tr>
        <th>Suppliers</th>
        <th><button type="button" class="add btn btn-warning">Add More</button></th>
    </tr>
</thead>
<tbody>
    <tr class="prototype">
        <td>
            {!! Form::select('supplier_id', $suppliers, null, ['class' => 'form-control select selectSuppliers', 'placeholder' => '-- Suppliers --', 'name' => 'supplier_id[]', 'required']) !!}
        </td>

        <td><button type="button" class="remove btn btn-danger">Delete</button></td>
    </tr>

</tbody>
</table>

I intend to make a selection without selecting the same value option. The problem I face is, I can still selecting the same supplier_id

this is the script I have

$(document).ready(function() {
    var id = 0;

    // Add button functionality
    $("table.dynatable button.add").click(function() {
        id++;
        var master = $(this).parents("table.dynatable");

        // Get a new row based on the prototype row
        var prot = master.find(".prototype:first-child").clone();
        prot.attr("class", "prototype")
        prot.find(".id").attr("value", id);

        master.find("tbody").append(prot);
    });

    // Remove button functionality
    $(".dynatable").on("click", ".remove" ,function() {
        var master = $(this).parents("table.dynatable");
        var rowlength = master.find('.prototype').length;
        if(rowlength > 1){
            $(this).parents("tr").remove();
        }else{
            alert("this is wrong");
        }
    });
});

//preventing same selection
$(".selectSuppliers").change(function(){
       var value = $(".selectSuppliers option:selected").val();
       var theDiv = $(".is" + value);
       $(".selectSuppliers option:selected").hide().siblings().removeProp('disabled');
 });

I tried to make the selected value to be hidden for the next select-option.

and this is another thing I tried

$("select").change(function() {
        $("select").not(this).find("option[value="+ $(this).val() + "]").attr('hidden', true);
    });

those functions I tried are a fail. and a bit jumpy. maybe because of my add and delete row function I made.

Is there anyhow we can make this work? please help and advice

Mar
23
3 weeks ago
Activity icon

Replied to Bootstrap Datepicker And Carbon Got "Unexpected Data Found. Data Missing" When Storing Data

IDK How, but it works. I think carbon doesn't know about dd/mm/yyyy

Thank you @silencebringer

Activity icon

Replied to Bootstrap Datepicker And Carbon Got "Unexpected Data Found. Data Missing" When Storing Data

$localDate = $request->dueDate;
dd($localDate);

the DD result

"31/03/2021"

thankyou for trying to help me @silencebringer

Activity icon

Replied to Bootstrap Datepicker And Carbon Got "Unexpected Data Found. Data Missing" When Storing Data

$dueDate =  Carbon::createFromFormat('dd/mm/yyyy', $localDate)->format('Y-m-d');

still have no luck

Carbon\Exceptions\InvalidFormatException
Unexpected data found. Data missing

:(

Activity icon

Started a new Conversation Bootstrap Datepicker And Carbon Got "Unexpected Data Found. Data Missing" When Storing Data

I have this datepicker without time H:i:s and cannot go through MySQL saying my data been missing, and my big guess is I'm having no time in my datepicker and I don't need to put time inside.

this is in my create form script

$('.datetimepicker-input').each(function(){
  $(this).datepicker({
    isRTL: false,
    format: 'dd/mm/yyyy',
    autoclose:true,
    startDate: new Date(),
  });
})

and this is in my store controller:

  $localDate = $request->dueDate;
  $dueDate =   Carbon::createFromFormat('dd/mm/yyyy', $localDate)->format('d-m-Y');

        Outcome::create([
            'order_id' => request('order_id'),
            'payment_method_options'  => request('payment_method_options'),
            'nominal'  => request('nominal'),
            'checknum'  => request('checknum'),
            'dueDate' => $dueDate,
        ]);

I've been tried using todatetimelocalstring and got no luck in it

$dueDate =   Carbon::createFromFormat('dd/mm/yyyy', $localDate)->toDateTimeLocalString();

and also I've been tried using carbon parse and got another thing to be a problem

Carbon::parse($localDate)->format('Y-m-d')

Could not parse '31/03/2021': DateTime::__construct(): Failed to parse time string (31/03/2021) at position 0 (3): Unexpected character

please help and advice

Jan
20
2 months ago
Activity icon

Replied to Ajax Error 500 For Calling A Model's Relationship

oh...you make it right. thank you. but my table is shrinking now, :/

Activity icon

Started a new Conversation Ajax Error 500 For Calling A Model's Relationship

Datatable setup well when I called just a single model. but then when I tried to call every relationship of this model, it went 500.

public function ShowInvoiceTable($id){
        $theProduct = Product::where('id', $id)->get();
        $invoice = $theProduct->invoice->load('customers');
return DataTables::of($invoice)
	->addColumn etc etc etc

please help

Jan
19
2 months ago
Activity icon

Replied to How To Get Data From Another Model Without Relation?

@nimrod Thankyou. it was hard for me.

Activity icon

Started a new Conversation How To Get Data From Another Model Without Relation?

I have a Product model is in relation with Invoice model, and Invoice has relation with Customer model.

so inside of my controller I wrote something in function show like:

public function show(Product $product)
 {
   $invoices = $product->invoice;
}

in dump data, I found everything I needed.

the problem is, how to get the customer name from the customer_id I just retrieved and make output in Datatable??

Jan
07
3 months ago
Activity icon

Replied to Get Data From Multiple Tables And Bound It With Order Based On Created Time

which migration to put this DB::statement? Do we have to create a new one or under the schema of product migration?

Activity icon

Replied to Get Data From Multiple Tables And Bound It With Order Based On Created Time

wow.. I will try this, but do I have to query this in my controller, or in my product model?

will this will work? a union method for laravel

Activity icon

Replied to Get Data From Multiple Tables And Bound It With Order Based On Created Time

hey @tray2 nice Profile Pict btw.

it's like SELECT created_at, quantity FROM invoice, order, returnOrder, returnInvoice, ORDERBY created_at DESC

but, I'm not sure about this query because many properties are inside the pivot table, like order_product, invoice_product, and so on...

but I can share what I imagine it's like:

=======================================================================
Date            Quantity                Type                Reason
=======================================================================
23-Jan-21           30                  order                   ----
24-Jan-21           5                  Invoice                  ----
24-Jan-21           1                  returnInvoice          broken Parts
27-Jan-21           1                  returnOrder            broken Parts

I try to make a flow for a quantity of a single product.

Activity icon

Replied to Get Data From Multiple Tables And Bound It With Order Based On Created Time

isn't it the same thing as compact('data')?

Activity icon

Started a new Conversation Get Data From Multiple Tables And Bound It With Order Based On Created Time

I have an Idea for creating a Product's stock flow. When it gets in and by who and otherwise.

but I'm stuck. Please help

Controller

 public function show(Product $product)
    {
        $invoice = $product->invoice;
        $order = $product->order;
        $retur = $product->returnInvoice;
        $failProd =$product->returnOrder;


         $data = array(
            'invoice' =>$invoice,
             'order' => $order,
             'retur' => $retur,
             'failProduct' => $failProd,
         );

         dd($data);


        return view('products.show', compact('invoice', 'product'));
    }

Product's Model

    public function invoice()
    {
        return $this->belongsToMany(Invoice::class, 'invoice_product')
->withPivot('quantity', 'invoicePrice', 'subtotal');
    }
    public function order()
    {
        return $this->belongsToMany(Order::class, 'order_product')
->withPivot('quantity', 'orderPrice', 'subtotal');
    }
    public function returnInvoice()
    {
        return $this->belongsToMany(Retur::class, 'product_retur')
->withPivot('quantity', 'invoicePrice', 'subtotal');
    }
    public function returnOrder()
    {
        return $this->belongsToMany(ReturnFailProduct::class, 'product_return_fail_product')
->withPivot('quantity', 'orderPrice', 'subtotal');
    }

and tried to dump the $data it's all 4 queries in here and I don't know how to call it into my view.

How to call all of them into a single Table and ordered them by the created date?? please help

Dec
30
3 months ago
Activity icon

Replied to Cannot Using Get(), I'm Always Using First()

@nakov this is confused me and I always forget about this. Then again, thanks, man.

Activity icon

Replied to Cannot Using Get(), I'm Always Using First()

I don't think it will solve the problem

@foreach ($retur->products as $returs)
   <tr style="background: tomato; color:white">
      <td class="text-center">{{ucwords($returs->name)}}</td>
      <td class="text-right">{{$returs->pivot->quantity}}</td>
      <td class="text-right">Rp. {{number_format($returs->pivot->invoicePrice)}}</td>
     <td class="text-right">Rp. {{number_format($returs->pivot->subtotal)}}</td>
   </tr>
@endforeach

and it still returning the error I describe:

Property [products] does not exist on this collection instance. 
Activity icon

Started a new Conversation Cannot Using Get(), I'm Always Using First()

in every app model, I called for the relationship I'm always using first() instead of get() .

Actually, I need to get all the records, from many to many relationships.

this is the database I have:

and this is what I did controller show:

$retur = Retur::where('invoice_id', $invoice->id)->first();
$retur->load('products');

when I try using get() method, it shows an error saying

Property [products] does not exist on this collection instance. 

I need to get all the records, to show. I need to sum() quantities, prices, and sub-totals from the records.

how to get all of it instead of the first row?

Dec
29
3 months ago
Activity icon

Replied to How To Input Laravel Validation Of LTE, With A Variable From A Pivot?

exactly I want to compare the value. The returned product's quantity value must not greater than the invoice product's quantity.

validating min and max are evaluated in the same fashion as the size rule. isn't it about 0-255 variable characters? But anyway, I did try what you suggested and it doesn't change.

and the required rule is not applied like if(!empty($input)), when I made no change in the input, the error message pops up The quantities.2 field is required.

Activity icon

Replied to How To Input Laravel Validation Of LTE, With A Variable From A Pivot?

I think it's getting close. thank you so much @michaloravec, but when I test the validation for quantities:

I put the return product's quantity over the invoice's quantity and it doesn't return the error message instead it continues to redirect.

example:

invoiceID = 2392
====================================================
products				quantities
====================================================
M&M					320 boxes
Ferrero					12 boxes

I put 13 boxes of Ferrero in the input and no error message.

ヾ(・д・ヾ) this is hard.

edited, and after I try to put no-change value, I hit the submit button without changing anything, the required messages pops up under both product's quantities

The quantities.2 field is required.

Edited, FYI I put the rules under the controller, and I don't have PHP artisan make:rules is it acceptable?

Activity icon

Replied to How To Input Laravel Validation Of LTE, With A Variable From A Pivot?

hi @michaloravec, I'm afraid that was not the solution I looking for.

because it was summing up all the quantities in a single invoice together,

what I mean is to validate each products-quantities from the invoice.

example :

invoiceID = 2392
====================================================
products				quantities
====================================================
M&M					320 boxes
Ferrero					12 boxes

so the customer cannot return the M&M less than 0 boxes nor more than 320 boxes, the same validation is applied for every product to be returned. Fererro cannot be returned less than 0 nor more than 12 boxes.

it's the validation from invoice->pivot->quantities that confused me.

I need the $prevQuantities have a value of each product's quantity,

Dec
28
3 months ago
Activity icon

Started a new Conversation How To Input Laravel Validation Of LTE, With A Variable From A Pivot?

This is an Invoice, Products, and Return Goods thing, I tried to make a return goods CRUD with less than or equal quantities from the invoice.

this is what I made in a store function

        $invoice = Invoice::where('id', $request->invoiceID)->first();
        $invoice = $invoice->load('products', 'customers');

        $prevQuantities = $invoice->products()->where('invoice_id', $invoice->id)->get()->pivot->quantity;
        dd($prevQuantities);

         $request->validate([
            'invoiceID' => 'required',
            'quantities.*' => 'required|gte:-1|lte:'.$prevQuantities,
            'reason'    => '',
        ]);

this line is the main problems

$prevQuantities = $invoice->products()->where('invoice_id', $invoice->id)->get()->pivot->quantity;

I can't get all the quantities from the Invoice I need to return. but when I change the function with first() it returning a single quantity (but of course it is).

the question is, how to get all the quantities from the Invoice, for validation of the lte:invoice-quantities?

Because the Invoice has many different products from a single customer, and a customer might returning some products or all of the products from their purchase.

Dec
26
3 months ago
Activity icon

Replied to Is There Any Good Laravel Packagist For Inventory?

I saw these packages before. and it does not contain what I needed most.

about items measuring units. because I think those are the most essential thing.

Dec
22
3 months ago
Activity icon

Replied to Is There Any Good Laravel Packagist For Inventory?

I don't think I can understand what you said. Can you please collaborate more?

Dec
19
3 months ago
Activity icon

Replied to Convert Date Format Into Moment Js

it is a static date format from the database? it's sort of an Invoice Date to be precise.

Activity icon

Replied to Convert Date Format Into Moment Js

I just change that and . . .

2020-12-17 14:35:10

the date doesn't change

Activity icon

Started a new Conversation Convert Date Format Into Moment Js

laravel blade HTML

<div id="datedisplay" class="">
	{{$invoice->first()->created_at}}
</div>

Javascript

$(document).ready( function () {
var locale = moment.locale('fr');
var theID = document.getElementById("datedisplay");

moment(theID).locale(locale).format('ll');
});

I think I don't quite understand how javascript works. please help.

Dec
18
3 months ago
Activity icon

Replied to Laravel Validation Doesn't Work As It Suppose.

it does the magic, ty again @nakov

but the error messages doesn't pop up

<input type="number" name="quantities[]" style="text-align: center; color:red"
class="form-control @error('quantities') is-invalid @enderror" required
value="{{$item->pivot->quantity}}" />

@error('quantities')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror

Activity icon

Replied to Laravel Validation Doesn't Work As It Suppose.

hi @carleogden

I don't think, what you wrote is any different from my past accomplishment. It just the same method.

@nakov answered it. it's 'quantities.*'

Activity icon

Replied to Laravel Validation Doesn't Work As It Suppose.

no, I mean something like

$number = 40;

$validatedData = $request->validate([
            'quantities.*' => ['required', 'numeric', 'gte:0', 'lte:$number'],
        ]);

I think I don't know how to put a variable inside a validation

Activity icon

Replied to Laravel Validation Doesn't Work As It Suppose.

hi @nakov

oh.. that's how it is... ty mate

and another thing if you don't mind. Out of topic tho, how to set the lte validation with the variable I made?

Activity icon

Started a new Conversation Laravel Validation Doesn't Work As It Suppose.

something create

<input type="number" name="quantities[]" style="text-align: center; color:red"
class="form-control @error('quantities') is-invalid @enderror" required
    value="{{$item->pivot->quantity}}" />

    @error('quantities')
    <span class="invalid-feedback" role="alert">
        <strong>{{ $message }}</strong>
    </span>
@enderror

and in Controller

    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'quantities' => ['required', 'numeric'],
        ]);

        dd($validatedData);
    }

the problem is, I keep getting an error message about my input is not a number, but it was a number.

what is wrong with this validation? please help

Dec
17
4 months ago
Activity icon

Replied to Calling A Relationship's Property Went Error

it does make sense.

so now I'm doing this, am I doing it right?

                @foreach ($invoice as $invoiceDetail)
                    @foreach ($invoiceDetail->products as $item)

thx for the advice @tippin.

Activity icon

Replied to Calling A Relationship's Property Went Error

I updated the question

Activity icon

Replied to Calling A Relationship's Property Went Error

i will update the question with the models app, yeah?

Activity icon

Started a new Conversation Calling A Relationship's Property Went Error

it is a common question I think, but I still don't get it even I read other people's discussions.

Property [name] does not exist on this collection instance.

I tried this

 @foreach ($invoice as $invoiceDetail)
                <tr id="">
                    <td>
                        {{$invoiceDetail->products->name}}
                    </td>
                    <td>
                        <input type="number" name="quantities[]" class="form-control"
                         value="" />
                    </td>
                    <td>
                        <input type="number" name="invoicePrices[]" class="form-control" disabled
                         value="" />
                    </td>
                </tr>

when I called an $InvoiceDetail->products relation, it shows everything I need. Meaning the property name does exist, but the error keeps telling me it is not exist

[{"id":2,"name":"prod exmp 2","price":"60000","stock":999,"return":15,"deleteStatus":0,"pivot":{"invoice_id":2,"product_id":2,"quantity":1,"subtotal":1,"invoicePrice":1}}]

Invoice Model

    protected $fillable = [
        'customer_id',

    ];

    public function customers()
    {
        return $this->belongsTo(Customer::class, 'customer_id', 'id');
    }
    public function products()
    {
        return $this->belongsToMany(Product::class)->withPivot(['quantity', 'subtotal', 'invoicePrice']);
    }

    public function returs()
    {
        return $this->belongsToMany(Retur::class);
    }

Products Model-has no relation, because I think I'm not calling anything starting from products

    protected $fillable = ['name','price','stock', 'retur', 'deleteStatus'];

    protected $hidden = ['created_at','updated_at'];

controller

    public function ReturnProduct($id)
    {

        $invoice = Invoice::where('id', $id)->get();

        $invoice->load('products', 'customers');

        return view('returs.returnproduct', compact('id', 'invoice'));
    }

any clue? please help

Dec
16
4 months ago
Activity icon

Started a new Conversation Is There Any Good Laravel Packagist For Inventory?

I have a project and need this thing, but I can't find a word to search for it.

to reduce development time, so I think it's better to have a packagist install.

I have Inventory which stock goods.

Each unit has a different volume and weight, or even have smaller units inside it. (Can you readers get it to this point? There were boxes inside a box. Like you guys buying a whole big M&M box)

Right now I stock everything in the smallest unit for example:

  • a sack of flour is 25Kg, and I stock it like 25.000 grams (if there is 20 sack of flour it's always stock like 20*25000= 500.000grams)
  • a big box of choco powder with 20 small boxes in it. and each small box has 5 small plastic packs in it. (if there is 10 box of choco powder it's always stock like 10*20*5= 1.000 packs)
and is there any packagist that can write down every product details and convert it in view like this:
  • flour stock left = 5 sacks - 2.5kg
  • choco powder stock left = 2 big box - 17 small boxes - 2 packs

please share it here if there is any packagist for this.

Activity icon

Started a new Conversation Good Packagist For Laravel Inventory System

I have a project and need this thing, but I can't find a word to search for it.

to reduce development time, so I think it's better to have a packagist install.

I have Inventory which stock goods.

Each unit has a different volume and weight, or even have smaller units inside it. (Can you readers get it to this point? There were boxes inside a box. Like you guys buying a whole big M&M box)

Right now I stock everything in the smallest unit for example:

  • a sack of flour is 25Kg, and I stock it like 25.000 grams (if there is 20 sack of flour it's always stock like 20*25000= 500.000grams)
  • a big box of choco powder with 20 small boxes in it. and each small box has 5 small plastic packs in it. (if there is 10 box of choco powder it's always stock like 10*20*5= 1.000 packs)
and what I requesting is a packagist that can write down every product details and convert it in view like:
  • flour stock left = 5 sacks - 2.5kg
  • choco powder stock left = 2 big box - 17 small boxes - 2 packs
Dec
11
4 months ago
Activity icon

Replied to Moment.js In Laravel Braces Output.

OK then, Thank you sincerely @nakov :D

Activity icon

Replied to Moment.js In Laravel Braces Output.

hi @nakov, I appreciate your thought.

So, clearly, there should be a long footer for an inventory system? I mean, I'm having many tables for invoices, orders, products, etc.

Each table has different values and I should name it differently in my footer. like so

var table = $('#invoice').DataTable

Is there any shorter code for this? a multi-purpose table maybe.

Dec
10
4 months ago
Activity icon

Started a new Conversation Moment.js In Laravel Braces Output.

can we do a moment locale in datatable using a normal PHP output?

so I have this table outputting data using normal laravel braces {{ }}

can we do the moment locale within?

@foreach ($invoices as $key=>$invoice)
<tr>
    <td id="transactionDate" class="transactionDate date">{{$invoice->created_at->format('d M Y')}} </td>
    <td>{{$invoice->customers->name}}</td>
    <td>
        <form action="{{ route('invoice.destroy', $invoice->id) }}" method="post" class="dflex justify-content-center">
            <a href="{{route('invoice.show', $invoice->id)}}" class="btn btn-primary btn-xs"> Lihat</a>
            <a href="{{route('invoice.edit', $invoice->id)}}" class="btn btn-info btn-xs"> Edit</a>
            <input class="btn btn-danger btn-xs" type="submit" value="Hapus" />
            @method('delete')
            @csrf
        </form>
    </td>
</tr>
@endforeach
</tbody>

this is what I tried with this date column

    <td id="transactionDate" class="transactionDate date">{{$invoice->created_at }} </td>

$(document).ready( function () {

moment('.date').format('LL');
});

and I already made the right datatable format date like below snippet, just curious if we can do the moment.js inside a Laravel braces.

var table = $('#invoice').DataTable({
            processing: true,
            serverSide: true,
            ajax: "{{ route('api.productsOut') }}",
            columns: [
                {data: 'date', name: 'date', render:function (data, type, row) {
                    var locale = moment.locale('id');
                    return (moment(data).isValid()) ? moment(data).locale(locale).format("LLLL") : "-";
                }},

Can we actually doing this kind of output using {{ }} ?

Dec
09
4 months ago
Activity icon

Replied to Audio Tag Won't Autoplay

I did read this article and also other forums with people's thoughts. And people saying, this jQuery is a bug that can't be solved.

$(document).ready(function() {
    $("#my_audio").get(0).play();
});

but sometimes I still can find a website with auto-playing music in it, like a full-ads website.

I just wanted to autoplay a Christmas song every time some visitor visit my project website :(

is there any way to do this? the autoplay audio thing.

Activity icon

Replied to Audio Tag Won't Autoplay

hi @sinnbeck, what do you mean by to hide it?

Those codes have no property or class display of none. I mean, they are all still visible and the autoplay won't autoplay.

my plan is, the display:none will be added if the autoplay is going well.

Activity icon

Started a new Conversation Audio Tag Won't Autoplay

I tried many different approaches. And still can't do this.

these are everything that I tried =

<embed src="/mainAssets/christmas/song.mp3" type="audio/mp3" autostart="true" hidden="true">
        <audio
            id="player"
            autoplay controls>
            <source src="/mainAssets/christmas/song.mp3" type="audio/mp3">
        </audio>
     <audio
            onload="play()"
            controls
            autoplay
            id="myAudio"
            src="/mainAssets/christmas/song.mp3">
                Your browser does not support the
                <code>audio</code> element.
        </audio>
<iframe src="/mainAssets/christmas/song.mp3" type="audio/mp3" allow="autoplay" id="audio" ></iframe>
<audio autoplay controls>
        <source src="/mainAssets/christmas/song.mp3" type="audio/mp3">
</audio>

The audio control is working, it just the autoplay won't work as supposed to be. The main goal is to do display:none of audio and make it autoplay each time the page is loaded.

How to make the mp3 is autoplay as the background music of our website?

please help.