In case someone runs into this as I did 'Not able to execute a .sh file: /bin/bash^M: bad interpreter', when running .sh . I found out that you have to convert the 'sh' script to Unix style first with 'dos2unix'.
Hey Emad you are awesome, please guide why you are using master seed instead of Faker or Seeder. You have best options to store data into data using Faker as Well as Seeding. Thanks in advance
Why not use laravel requests to validate input, for example in this case why not create StudentRequest and use it instead of Request?? Any advantage following your style over it?
Hello. You can if you like. But we are applying the repository pattern. All queries must be done inside the repository file. The service would then call the repository to perform and return the result. The idea is to separate logic. For the backend we have mainly 3 layers. 1. Controller - calls the corresponding service and return the api response. 2. Service - handle all logic. 3. Repository - handle all database related logic.
It was working up to the end of the video. I don't know why it behaves like this, each endpoint I try to access, throws the following Illuminate\Contracts\Container\BindingResolutionException: Target class [App\Modules\Students\CoursesService] does not exist. in file /Users/developer/Documents/code/api-student/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 877
You need to double check your namespaces. CoursesServices namespace should be under App\Modules\Courses\CoursesService not App\Modules\Students\CoursesService
For everyone who has the problem where one can add more students than the capacity of a course, the problem is located in CoursesRepository, in $selectColumns, he forgot to add AS totalStudentsEnrolled when counting the number of enrolled students. So it should be: (SELECT COUNT(*) FROM students_courses_enrollments WHERE students_courses_enrollments.courses_id = courses_id AND students_courses_enrollments.deleted_at IS NULL ) AS totalStudentsEnrolled
Underrated Channel... looking forward for more advance laravel api tutorial, and anything about laravel, tysm it is really helpful for me!
Great Job Emad!! I saw your videos and they are very educational
just completed the course!, i hope u can make about laravel backend with more feature, such as search, filter and more... tysm!
Hello yes that's my plan. My next release will include indexing, filtering, ordering etc... :)
@@emadzaamout omg, i really excited to see that!
@@emadzaamout is it already out?
In case someone runs into this as I did 'Not able to execute a .sh file: /bin/bash^M: bad interpreter', when running .sh . I found out that you have to convert the 'sh' script to Unix style first with 'dos2unix'.
Excellent 👌👌
Hey Emad you are awesome, please guide why you are using master seed instead of Faker or Seeder. You have best options to store data into data using Faker as Well as Seeding. Thanks in advance
how much faster is this way of design?
where did u learn this? any learning resources you can recommend?
Why not use laravel requests to validate input, for example in this case why not create StudentRequest and use it instead of Request?? Any advantage following your style over it?
why not use DB raw SQL statement in the service class?
Hello. You can if you like. But we are applying the repository pattern. All queries must be done inside the repository file. The service would then call the repository to perform and return the result.
The idea is to separate logic. For the backend we have mainly 3 layers.
1. Controller - calls the corresponding service and return the api response.
2. Service - handle all logic.
3. Repository - handle all database related logic.
👍👍👍
nice but why are you not using seeders?
why we need to make the request into array first than validate it ? why we dont just use request ?
You are super
It was working up to the end of the video. I don't know why it behaves like this, each endpoint I try to access, throws the following Illuminate\Contracts\Container\BindingResolutionException: Target class [App\Modules\Students\CoursesService] does not exist. in file /Users/developer/Documents/code/api-student/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 877
You need to double check your namespaces.
CoursesServices namespace should be under
App\Modules\Courses\CoursesService not
App\Modules\Students\CoursesService
error zsh: permission denied: ./scripts/install.sh
You need to give the file permission to run
chmod u+x ./scripts/install.sh
@@emadzaamout Done.Works
For everyone who has the problem where one can add more students than the capacity of a course, the problem is located in CoursesRepository, in $selectColumns, he forgot to add AS totalStudentsEnrolled when counting the number of enrolled students.
So it should be: (SELECT COUNT(*)
FROM students_courses_enrollments
WHERE students_courses_enrollments.courses_id = courses_id
AND students_courses_enrollments.deleted_at IS NULL
) AS totalStudentsEnrolled