santino
2 months ago

Help calling information from products model

Posted 2 months ago by santino

Hi, I want to know whats the best way to make this action, I am calling all the products of a model table like this and get this object model


return $products = Product::all();

[
{
"id": 1,
"icon": "fa fa-house-user",
"name": "Client Licence",
"slug": "Client-Licence",
"value": 25,
"income": 0.1,
"description": "A client Licence is an user that only can hire services on TradeLinn, also can upgrade his account to service provider or to Independent Distributor.",
"created_at": "2020-08-08T23:53:56.000000Z",
"updated_at": "2020-08-08T23:53:56.000000Z"
},
{
"id": 2,
"icon": "fa fa-house-user",
"name": "Distributor Licence",
"slug": "Distributor-Licence",
"value": 90,
"income": 0.45,
"description": "A Independent Distributor Licence is an user that can affiliate Clients, Service Providers and Independent Distributors, also can hire and offer services on TradeLinn",
"created_at": "2020-08-08T23:53:56.000000Z",
"updated_at": "2020-08-08T23:53:56.000000Z"
},
{
"id": 3,
"icon": "fa fa-users",
"name": "Provider Licence",
"slug": "Provider-Licence",
"value": 45,
"income": 0.25,
"description": "A Service Provider Licence is an user that can hire and offer services on TradeLinn, also can upgrade his account for Independent Distributor Licence.",
"created_at": "2020-08-08T23:53:56.000000Z",
"updated_at": "2020-08-08T23:53:56.000000Z"
},
{
"id": 4,
"icon": "fas fa",
"name": "new product",
"slug": "new-product",
"value": 43,
"income": 0.45,
"description": "soy un boton de pruebas",
"created_at": "2020-08-08T23:57:08.000000Z",
"updated_at": "2020-08-08T23:57:08.000000Z"
}
]

nothing fancy, it returns all the products , BUT now I want to remove all products EXEPT

Client-Licence - want to call this from its slug no from ID

Provider-Licence - want to call this from its slug no from ID

so what is the correct way to say like, okay got the collection now remove all exept->( 'slug' , Client-Licence )

Any help is well received

Regards Daniel

Please sign in or create an account to participate in this conversation.