jeudi 17 juin 2021

first() not working on string with more than one words [closed]

private function getBrandIdFromName($brandName){
        $brand = Brand::query()->where('slug',$brandName)->first();
        if($brand){
            return $brand->id;
        }else{
            $newBrand = [
                'name'=>$brandName,
                'is_active'=>"1",
                'meta'=>[
                    'meta_title'=>null,
                    'meta_description'=>null,
                ]
            ];
            $brand = Brand::create($newBrand);
            return $brand->id;
        }
    }

here 'slug' and 'name' are column in different tables

for one word like "puma" its working fine. but for more than one word like "puma world" it not working well i.e. its importing name again and again. I dont know its reason wheather its causing because of first() or any other mistake. if anyone know please do help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire