How to convert dot (.) to string in Laravel with Mysql query's function whereColumn

Issue

I have this kind of error in a subid I have. In the argument that laravel automatically place an ‘ after that. How can I get rid of that or how can I convert my . to not to be string concatenate expression and convert it to become string instead?

Here is my controller code which have the syntax :

 public function datavolumechart() {
    $volume = lokasipekerjaan::select(
        DB::raw("YEAR(tanggal) as year"),
        DB::raw("SUM(volume) as total_volume
        "),
    )->havingRaw('total_volume < 100000000', [1])->whereColumn('subid','1.A.A.1')->orderBy(DB::raw("WEEK(tanggal)"))
    ->groupBy(DB::raw("WEEK(tanggal)"))
    ->pluck('total_volume','year');

            return view('admin.home',compact('volume'));
}

Solution

i think i just wrote false msyql syntax,what i need to do is just :
erase ->havingRaw(‘total_volume < 100000000’, [1]) and ->whereColumn,To match a value then i just need to use ->where(‘subid’, ‘1.A.A.1’)

public function datavolumechart(){
$string = '1.A.A.1';
$volume = lokasipekerjaan::select(
    DB::raw("YEAR(tanggal) as year"),
    DB::raw("SUM(volume) as total_volume
    "),
)->where('subid','LIKE','%'.$string.'%')->orderBy(DB::raw("WEEK(tanggal)"))
    ->groupBy(DB::raw("WEEK(tanggal)"))
    ->pluck('total_volume','year');

        return view('admin.home',compact('volume'));

}

Answered By – Muhammad Bayu Kurniawan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published