Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

333
Views
How to return a string that only has a special value of text that has been set?

enter image description here

I have data like the image above. However, in the "Bahan-bahan" column, I only want to display the values ​​in the predefined custom values ​​below.

<?php 

return [
    'shopping_list' => [
            '1' => 'Ikan Bawal',
            '2' => 'Udang Segar',
            '3' => 'Daging Ayam',
            '4' => 'Daging Sapi',
        ],
    ];

?>

How to make this using PHP Laravel or javascript?

Following this, the code I have created using Laravel 7.

public function index(Request $request)
{
    $payment_method = PaymentMethod::Where('payment_type', 1)->get();
    if (request()->ajax()) {

        $category = Category::find(6);

        $orders = $category->products()
        ->withCount([
            'orderSummaries as order_count' => function ($query) {
                $query->whereHas('order', function (Builder $query) {
                    $query->where('order_status', 2);
                });
            }
        ])
        ->whereHas('orderSummaries', function (Builder $query) {
            $query->whereHas('order', function (Builder $query) {
                $query->where('order_status', 2);
            });
        })
        ->get();

        return DataTables::of($orders)
            ->addIndexColumn()
            ->editColumn('ingredient', function($item) {
                $text = \Str::between($item->description, 'Bahan-bahan:','Cara Membuat');

                return nl2br($text);
            })
            ->rawColumns(['name','order_count', 'ingredient'])
            ->make(true);
    }
    return view('admin.marketplace.shoppingList.index',[
        'title'          => 'Belanja',
        'subtitle'       => 'Daftar Belanja',
        'payment_method' => $payment_method,
    ]);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!