B
B
BonBon Slick2016-12-04 21:17:43
Laravel
BonBon Slick, 2016-12-04 21:17:43

How can $request->all()->except(['my_parametr']) take everything except from the request?

It doesn't work like this:
$request->all()->except(['product_slug'])
If the slug is empty, you need to generate it, therefore exclude the one from the request, and create your own, something like:

Product::create($request->all()->except(['product_slug']) + ['product_slug' => $generatedSlug] );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2016-12-04
@BonBonSlick

$tmp_arr = $request->all();
if(empty($tmp['product_slug'])){
    $tmp_arr['product_slug'] = $generatedSlug;
}
Product::create($tmp_arr);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question