Posts

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 perform sql LIKE operation on Firebase in Laravel PHP #16

Image
How to perform the like queries on Firebase 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. 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. 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 named 'Tim Dane'. Now you have to search this student from whole list, so you start time 'Tim', so atleast it should be match one matching word. So do Firebase return has "Tim Dane" on search of "...

Chapter 15 - Laravel with Firebase Sign In and maintain logged in session using middleware

Image
In this chapter, we will learn how can we implement a login page and make a user login. Then maintain a session for other page queries and logout to destroy session. Before we start, we assume you have all knowledge of setting up the Firebase Authentication. If not please read this  Chapter 6 First of all, below is the code of login method with takes email and password and checks if the credentials is correct or incorrect. try { $logged_user = app('firebase.auth')->verifyPassword($request->emailaddress, $request->password); //Credentials are correct } catch (\Kreait\Firebase\Exception\Auth\InvalidPassword $ex) { return back()->withErrors(['Credentials are incorrect']); } Now if Credentials are correct, then store the uid in the Laravel Session \Session::put('uid', $logged_user->uid); Now create a custom middleware. lets us name it as 'firebase...

How to use firebase reset password custom and manage & reset forgotten users passwords - #14

Image
Learn how to use custom firebase reset password and manage & reset forgotten users passwords. Detailed how to implement the custom Firebase Auth Forgot/Reset Password template and send to user on Forgot Password Request. And the reset password URL would contain URL to your site instead of Firebase default URL. And on visit of this URL, how to call verify method of Firebase Auth and Form containing password fields submission in Laravel PHP with little help of JavaScript SDK. Here, before we start, please read this Email verification chapter  https://laravelwithfirebase.blogspot.com/2020/04/chapter-13-implement-custom-firebase-auth-email-verification-template-replace-default-view-using-laravel-php.html Most of below content would be same. Now lets begin to customize the URL, you get in your firebase email verification template. It looks like something  https://test-cc4d3.firebaseapp.com/__/auth/action?mode=<action>&oob...

How to create custom firebase email templates and action handlers link #13

Image
Learn how to create custom email action handlers and change the Firebase email templates using Firebase email link authentication. Detailed how to implement the custom Firebase Auth Email verification template and send to user on signup. And the verification URL would contain URL to your site instead of Firebase default URL. And on visit of this URL, how to call verify method of Firebase Auth in Laravel PHP with little help of JavaScript SDK. Here, we assume, your are clear about Firebase Auth and you have enabled the Email/Password in the Sign-in method Now lets begin to customize the URL, you get in your firebase email verification template. It looks like something  https://test-cc4d3.firebaseapp.com/__/auth/action?mode=<action>&oobCode=<code> Here, in above image, you have edit button for the editing the template. Click on that, then you will have "customize action URL" link at the bottom...

Chapter 12 - Delete data from Firebase using Laravel PHP

Image
In this chapter, we will learn how to delete the data from Firebase Cloud Firestore database collection using Laravel Framework PHP SDK. Now consider the following list of students in the 'Student' collection Suppose you want to delete the Student by document id '8suVf4FphzZLuTFJtdFe', you have to fire the below query. app('firebase.firestore')->database()->collection('Student')->document('8suVf4FphzZLuTFJtdFe')->delete(); This will delete the Student data from Student collection. Now if you have to delete the student having id = 3, then this can be done by the following query $students = app('firebase.firestore')->database()->collection('Student')->where('id','==',3)->limit(1)->documents(); $students ->rows()[0]->delete(); Now consider if you have to delete students having 'passoutyear' ...

Chapter 11 - Update data to Firebase using Laravel PHP

Image
In this chapter, we will learn how to update data to Firebase Cloud Firestore using Laravel PHP package. Consider the list of Student in Firebase Cloud Firestore. We would update these student data for all different type of datatypes of fields. Update normal string field name $student = app('firebase.firestore')->database()->collection('Student')->document(<studentid>); Example $student = app('firebase.firestore')->database()->collection('Student')->document('defT5uT7SDu9K5RFtIdl') ->update([ ['path' => 'name', 'value' => 'John Kone'] ]); After update, firebase will look like this Before updating or even inserting a value for fields like Integer or float, boolean make sure you convert your request params to specific datatype $student = app('...

Chapter 10 - Fetch data from Firebase performing Simple and compound queries using Laravel PHP

Image
In this chapter, we will learn how to can fetch data from Firebase Cloud Firestore by performing simple and compound queries using Laravel PHP package. Consider the list of Student in Firebase Cloud Firestore. We would fetch these student data using all example of queries. Fetch the normal list $students = app('firebase.firestore')->database()->collection('Student')->documents(); print_r('Total records: '.$students->size()); foreach($students as $stu) { if($stu->exists()){ print_r('Student ID = '.$stu->id()); print_r('Student Name = '.$stu->data()['name']); } } Now search query, search by name in student list $students = app('firebase.firestore')->database()->collection('Student')->documents() ->where('name','==','John Doe'); Remember there is no...