Category : regex

We have a multiple route in laravel and one of our url we have this url: http://sample.com/U9JD1 as our short urls, here this shorted url string length is fixed by 5 character and that could be both of string and number like with U9JD1 now how can i use where clause in this route: Route::get(‘{shortCode?}’, ..

Read more

hello i have laravel blade and here is the part that have the issue @php $reg_exUrl = "/(http|https|ftp|ftps)://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/S*)?/"; @endphp <div class="message"> @php $text = nl2br(e($message)); @endphp @if(preg_match($reg_exUrl, $text, $url)){!! preg_replace($reg_exUrl, ‘<a href="$0" target="_blank">$0</a> ‘, $text) !!} @else {!!$text!!} @endif </div> this works good if the link is only in the text but if it got ..

Read more

In Laravel, we can use the * wildcard notation for validating input from arrays: $validator = Validator::make($request->all(), [ ‘person.*.email’ => ’email|unique:users’, ‘person.*.first_name’ => ‘required_with:person.*.last_name’, ]); What is the simplest way to access all keys matching the input using the same notation? For example, using "person.*.email" I want to retrieve ["person.0.email", "person.1.email] if there are two ..

Read more

Here is what it looks like after getting value from CDATA via simplexmlelement $data = "{customertype=New, Telephone=09832354544, CITY=Henfield, LASTNAME=C, TicketNo=123456, FIRSTNAME=Alex, Id=10001273, testfield=123456, COMPANY=Camp1}" I tried looking into solutions in google but i am not able to find one which would convert this set of strings to array. I want this data to convert into ..

Read more

Im web.php, I have working routes. Route::get(‘post/{post?}/{id?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{tag:slug?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{user?}/{id?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{location?}’, [PostController::class, ‘__invoke’]); And I wanted it a little bit shorter. Route with post parameter working fine but the two others got 404. Route::get(‘post/{post?}/{id?}’, [PostController::class, ‘__invoke’]) ->where(‘post|id’, ‘tag:slug|user|location’); In RouteServiceProvider.php, I have bind two route with their parameters. Route::bind(‘post’, function ..

Read more

Im web.php, I have working routes. Route::get(‘post/{post?}/{id?}’, PostController::class); Route::get(‘post/{tag:slug?}’, PostController::class); Route::get(‘post/{user?}/{id?}’, PostController::class); Route::get(‘post/{location?}’, PostController::class); And I wanted it shorter. Route with post parameter working fine but the others got 404. Route::get(‘post/{post?}/{id?}’, PostController::class) ->where(‘post|id’, ‘tag:slug|user|location’); In RouteServiceProvider.php, I have route binding for post and user parameters. Here is my PostController.php public function __invoke(Request $request, Post $post ..

Read more

private function getCategoryIdsFromNames($categories,$subCategory){ $categoryArray = $this->explode($categories); if(!$categoryArray) return false; $categoryIds = []; foreach ($categoryArray as $categoryName){ $category = CategoryTranslation::query()->where(‘name’,$categoryName)->where(‘locale’,’en’)->first(); if($category){ $categoryIds[] = $category->category_id; }else{ $newCategory = [ ‘name’=>$categoryName, ‘is_active’=>"1", ‘parent_id’=>null, ‘is_searchable’=>"1", ]; $category = Category::query()->create($newCategory); $categoryIds[] = $category->id; } } return $categoryIds; } This code currently importing one category for one product. I want to ..

Read more

I have a viewers JSON column in the products table that hold a similar value example: [{"at": "2021-06-21T18:58:39", "age": 30, "country_iso_code": "US"}, {"at": "2021-06-18T11:13:13", "age": 20, "country_iso_code": "PH"}, {"at": "2021-06-25T23:57:12", "age": 45, "country_iso_code": "ET"}, {"at": "2021-06-27T17:01:14", "age": 18, "country_iso_code": "DZ"} So, I’m trying to get rows that contain numbers between two JSON age property values, ..

Read more

recently I have difficulty replacing every <img> tag src to the data-lazyload-src. My expected output will be <img src="facebook.com/image.png" class="img big-img" data-lazyload-src="tt.com/image_01_140x140.png"/> to <img class="img big-img" src="tt.com/image_01_140x140.png"/> I know these can be done by using PHP preg_replace but I am quite new to regex. Meanwhile, I would like to replace it completely in backend instead ..

Read more

I have a student result file I want to search from there with student roll to show the result next to that roll.. The format of my result sheet 300001 (3.63) 300002 (3.28) 300011 {66672 (T)} 300017 {66641 (T), 66652 (T), 66672 (T), 66678 (T)} Here 300001 is a roll and the result of the ..

Read more

i go this view file that only working to upload image types file, need help to make it can do upload different extension of file leets says .doc or .pdf thank you controler: public function pengajuan_baru_post() if($layanan->dokumenLayanan->count() > 0){ if($this->request->has([‘dokumen_id’, ‘dokumen’])){ foreach ($this->request->dokumen as $dok) { if(!empty($dok)){ if(empty(preg_match(‘/^data:image/(?<extension>(?:png|gif|jpg|jpeg|webp));base64,(?<image>.+)$/’, $dok))){ return back()->with(‘warning’, ‘Pastikan format dokumen yang ..

Read more

I have 2 regular expressions in the database: 1. ^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$ 2. ^(bnb1)[0-9a-z]{38}$ that I use for validation as the following code $this->validate([ ‘address’ => ‘required|regex:/’.$this->networkData->address_regex.’/’, ]); There is no problem with the second regex But for the first regex the following error is given preg_match(): No ending delimiter ‘/’ found There were many questions for ..

Read more