Posts

Showing posts from March, 2020

How to make Firebase query search not case sensitive #18

Image
How to make Firebase query search not case sensitive because you know Firebase provide exact match "==" with case sensitive. So we will solve this issue in the chapter in detail. We will use the Laravel PHP SDK for the firebase for all the queries stuff. Also we will see case insensitive sorting with Firebase orderBy using Firebase search ignoring case. Now lets consider a simple example, you have 'Student' list and you want to search by name. So the main use of any search is that, you insert one or two characters and the system should search the most matching one, but that not the case in Firebase. Firebase is a case sensitive. Means string "Name" and "name" are two different values for Firebase. All Firebase developers are facing this issue, which is most basic necessity. So lets first understand, currently what is provided by Firebase. See the below example of Student List. Now here you see, we have a Student ...

How to auto increment a Cloud Firestore document existing number field id #9

Image
Learn How to auto increment a Cloud Firestore document existing number field id. In this chapter, we will learn how to insert a data with an auto increment id and using it an unique id instead of default Push ID provided by Firebase. Consider the following example: You have a Student collection and it has data with auto incremented value. When you insert the next, it should have id = 4. Now Firebase doesnot provide anything related to this autoincrement feature. It has only unique id generated by its logic. So we will do some manual coding for it. Now, you have the easy solution is to get the total size of the list of documents +1. Consider the following code $newid = app('firebase.firestore')->database()->collection('Student') ->documents()->size()+$i; //Insert new record app('firebase.firestore')->database()->collection('Student') ->document($ne...

Chapter 8 - Add data to Firebase using Laravel PHP

Image
In this chapter, we will learn how to insert data in Firebase Cloud Firestore from Laravel Firebase SDK demonstrating usage of various data types. Insert a simple student data in Student collection $stuRef = app('firebase.firestore')->database()->collection('Student')->newDocument(); $stuRef->set([ 'firstname' => 'John', 'lastname' => 'Doe', 'age' => 30 ]); Here firebase autoconsider the data type i.e firstname is string, lastname is string and age is number. Following are the example of sending different datatypes $docRef->set([ 'stringExample' => 'Hello World', 'booleanExample' => true, 'numberExample' => 3.14159265, 'timestampExample' => new \Google\Cloud\Core\Timestamp(new \DateTime(date('Y-m-d H:i:s', strtotime('2020-03-03 23:12:55')...