vendredi 13 janvier 2023

save and update the order of concatenation in the controller

I am looking to concatenate columns into a single , and be able to change the order that I can save it here is the schema of my table:

id col1 col2 col3 separation order ref
A 320 Audi - 'col1','col2','col3' A-320-Audi
A 120 Audi * 'col3','col2','col1' Audi120A
c 220 Aaudi / 'col2','col3','col1' 220/audi/c

in my modification form the user can change the values ​​of the columns also the separation and the order but I also want to save the order that the user has chosen to use it in other pages

in my controller:

serials = Serial::findOrFail($id);
    $serials->update([
        'col1' => $request['col1'],
        'col2' => $request['col2'],
        'col3' => $request['col3'],
        'separation' => $request['separation'],
        'order' => $request['order'],
    ]);
DB::statement(DB::raw("UPDATE serials SET ref = CONCAT_WS(separation,order????) WHERE id = $id"));

problem 1:

how to register the chosen order correctly

in my input request of order someting like = 'col1','col2','col3'

problem 2 :

how to retrieve the value of the order and correctly execute the concatenation from the column order someting like :

DB::statement(DB::raw("UPDATE serials SET ref = CONCAT_WS(separation, ???'column:order'????) WHERE id = $id"));


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/yUpKR4t
via IFTTT

Aucun commentaire:

Enregistrer un commentaire