WebReinvent Technologies
CoEnterprise Interview Questions and Answers
Q1. What is international format to store dates in PHP? How to access it?
The international format to store dates in PHP is 'Y-m-d H:i:s'. It can be accessed using the date() function.
Use 'Y-m-d H:i:s' format to store dates in PHP
Access it using the date() function in PHP
Q2. What is difference between jobs and batch?
Jobs are individual tasks that are executed independently, while batches are groups of tasks executed together.
Jobs are typically smaller in scope and run independently, while batches involve multiple tasks grouped together.
Jobs can be queued and processed asynchronously, while batches are usually executed synchronously.
Examples of jobs include sending an email, processing an image, or updating a database record. Examples of batches include importing a CSV file, running a ser...read more
Q3. What is polymorphic relationship?
Polymorphic relationship is a type of relationship in which a model can belong to multiple other models on a single association.
Allows a model to belong to multiple other models on a single association
Uses a single column in the database to store the type of the related model
Commonly used in scenarios where a model can belong to multiple other models such as comments, likes, or tags
Q4. What is trait used for?
Traits are used in PHP to group functionality in a fine-grained and reusable way.
Traits allow you to reuse methods in multiple classes without inheritance limitations.
They provide a way to compose classes that is more flexible than single inheritance.
Traits can be used to share methods among classes that are unrelated in terms of inheritance.
An example of using traits in Laravel is the 'SoftDeletes' trait which adds soft deletion capabilities to models.
Q5. What are the observers.
Observers in Laravel are classes that listen for specific model events and trigger actions based on those events.
Observers are used to decouple event listeners from models.
They can listen for various model events like creating, updating, deleting, etc.
Observers are defined by creating a class that extends the Eloquent model observer class.
Example: Creating a UserObserver class to send an email notification when a new user is created.
Q6. What are accessor and mutator
Accessors and mutators are methods used in Laravel Eloquent models to manipulate attribute values before retrieving or saving them.
Accessors are used to modify attribute values when retrieving them from the database
Mutators are used to modify attribute values before saving them to the database
Accessors and mutators are defined as methods in the Eloquent model class
Example: public function getFullNameAttribute() { return $this->first_name . ' ' . $this->last_name; }
Reviews
Interviews
Salaries
Users/Month