Posts

Showing posts with the label Firestore Queries

Chapter 5 - Integrate Laravel with Google Firebase connecting Cloud Firestore

Image
In this chapter, we will create a Laravel project and connect it with the Cloud Firestore with installing all necessary packages and build some basic queries. Step 1: Install a fresh Laravel Project with name my-project composer create-project --prefer-dist laravel/laravel my-project Step 2: Setup a Firebase account and Cloud Firestore Database A detail chapter on this topic is available here  https://laravelwithfirebase.blogspot.com/2020/02/chapter-3-creating-project-in-firebase-for-laravel-php.html Step 3: Use the Laravel package built over Firebase PHP Admin SDK by Kreait The package url on Github: https://github.com/kreait/laravel-firebase. We have already explain the Firebase PHP Admin SDK in previous chapters by the same Author. So this code has been used by lot of people and is highly maintainable. Run the following command to install the package. composer require kreait/laravel-firebase ...

Chapter 2 - MySQL structure comparison with Firebase structure

Image
In this chapter, we will discuss how you can decide the structure of your data in Firebase as compared to you do it in MySQL. So lets begin. Consider a simple example of two tables "students" and "courses" and a relationship table which stores the info of student applying the specific courses as student_course. Following is the student table with the basic fields firstname, lastname etc. The second is the courses table with the basic fields name, duration, cost etc. The third one is the Student_Course as relationship table to store the data of student applying to which course. Now your normal query in MySQL to fetch a particular course with the applied student would be this. select c.name as course, s.firstname as student from courses as c left join student_course as sc on sc.course_id = c.id left join students as s on s.id = sc.student_id where c.id = 1 For Laravel lovers (assuming you know the Eloquent ORM. Don't know? co...