
Eloquent ORM Basics
Models, CRUD operations, query builder, mass assignment, timestamps, soft deletes, accessors, mutators
1What naming convention does Eloquent use by default to deduce the table name from the model name?
What naming convention does Eloquent use by default to deduce the table name from the model name?
Jawaban
Eloquent uses the plural snake_case of the class name to deduce the table name. For example, the User model corresponds to the users table, and BlogPost corresponds to blog_posts. This convention can be overridden by defining the $table property in the model.
2Which Eloquent method allows creating AND saving a new model in a single operation?
Which Eloquent method allows creating AND saving a new model in a single operation?
Jawaban
The create() method allows creating and saving a model in a single operation by accepting an array of attributes. It requires attributes to be listed in the $fillable property or $guarded to be defined to protect against mass assignment. Unlike new Model() followed by save(), create() combines these two steps.
3What happens if attempting to mass assign an attribute that is not in $fillable?
What happens if attempting to mass assign an attribute that is not in $fillable?
Jawaban
Laravel throws a MassAssignmentException to protect against mass assignment vulnerabilities. This protection prevents malicious users from injecting unauthorized attributes via HTTP requests. You must either add the attribute to $fillable, use $guarded to protect only certain attributes, or use forceFill() to bypass protection.
What is the difference between the find() and findOrFail() methods in Eloquent?
How does Eloquent automatically handle the created_at and updated_at columns?
+19 pertanyaan wawancara
Topik wawancara Laravel lainnya
PHP Basics
PHP OOP Essentials
Composer & Autoloading
Laravel Fundamentals
Laravel Routing
Blade Templates
Request & Response
Eloquent Relationships
Migrations & Schema Builder
Validation & Forms
Authentication
Authorization & Policies
API Resources & Authentication
Middleware
Service Container & DI
Queues & Jobs
Events & Listeners
Notifications & Mail
File Storage
Testing & PHPUnit
Caching
Livewire & Inertia
Eloquent Advanced
Repository Pattern
Laravel Packages
Performance Optimization
Security Best Practices
Laravel Octane
Laravel Distributed Systems
Observability & Monitoring
Deployment & DevOps
Kuasai Laravel untuk wawancara berikutnya
Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.
Mulai gratis