1

iam trying to give url to my image, so i try to use concat. but in there i have trouble if the concat just use to 1 column i can make it. but is use 3 column, so i dont now how to do it ?

this is my controller :

$site = asset("uploads").'/';
        $result = DB::table('log_patrol_details')
        ->select("*",DB::raw("concat('$site',photo1) as photo1"))
        ->where('id_log_patrols', $request->input('id_log_patrols'))
        ->orderBy('id', 'desc')
        ->first();
        if(count($result)==0) {
            $response['api_status'] = 0;
            $response['api_message'] = "Belum ada data";
        }else{
            $response['api_status'] = 1;
            $response['api_message'] = "success";
            $response['items'] = $result;
        }
        return response()->json($response);

iam try to add concat to my photo1, photo2, and photo3

image

1 Answer 1

1

I'm not fully sure I've understood your question. Can't you just add two more statements to your select for photo2 and photo3 and you're good to go?

->select("*",
    DB::raw("concat('$site',photo1) as photo1"),
    DB::raw("concat('$site',photo2) as photo2"),
    DB::raw("concat('$site',photo3) as photo3")
)
Sign up to request clarification or add additional context in comments.

2 Comments

iam try it : ("concat('$site',photo2) as photo2"),("concat('$site',photo3) as photo3") just like that so thanks ya for the correction :D
@AdamProjo You're welcome. If it worked for you please accept the answer. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.