If you are just showing them using blade, you can easily trim it there.
{{Str::after($row->attachment_files, '.')}}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
guys, i have a column name called attachment_files in my query and save it in DB this way 1641210480.Python-Cheat-Sheet.pdf.
i need when i make the query to return it this way Python-Cheat-Sheet.pdf
how can i do it?
$getMerchant = Merchant::leftjoin('ratings', 'ratings.merchant_id', '=', 'merchants.id', 'merchant_qualification', 'merchant_qualification.qualification')
->select('merchants.*', DB::raw('round(avg(ratings.rate),1) as rate'))
->when($request->qualification_id > 0, function ($builder) use ($request) {
$builder->whereHas('merchant_qualification.qualification', function ($builder) use ($request) {
$builder->where('id', $request->qualification_id);
});
})
->when(($request->date != null && $request->date != 0) || ($request->time != null && $request->time != 0), function ($b) use ($request) {
$b->whereHas('merchantAvailability', function ($b) use ($request) {
if (($request->date != null && $request->date != 0)) {
$b->where('date', $request->date);
}
if ($request->time != null && $request->time != 0) {
$b->where('from_time', '<=', $request->time)
->where('to_time', '>', $request->time);
}
});
})
->where($cond)
->where('is_approved', '=', '1')
->orderby($orderColumns, $orderDirection)
->groupBy('id')
->when($request->rate > 0, function ($builder) use ($request) {
return $builder->having(DB::raw('round(avg(ratings.rate),1)'), '>', $request->rate - 1)
->having(DB::raw('round(avg(ratings.rate),1)'), '<=', $request->rate);
})
->with($det)
->limit($request->limit)
->get();
return $getMerchant;
} catch (\Exception $e) {
return $this->returnMessage($e->getMessage());
}
}
public function getMerchants(Request $request)
{
$request->request->add(['showDetails' => '0']);
$getMerchant = $this->getMerchantData($request);
$getMerchant = $getMerchant->map(function ($getMerchant) {
return (object)$getMerchant;
});
return $this->showAll($getMerchant);
}
@eliekhazzaka You just add to your select
->select('merchants.*', DB::raw('round(avg(ratings.rate),1) as rate'), DB::raw('SUBSTRING(attachment_files, 11) AS attach_file_name'))
Please or to participate in this conversation.