Skip to main content

Vue - Laravel Developer Interview questions

 Code Questions
1. I've already created a database table that I want to use with Laravel's ORM. How would I setup a class to do that?
To set up a class to use with Laravel's ORM (Eloquent), you would create a model class that extends Laravel's Illuminate\Database\Eloquent\Model class. Here's an  
2. Laravel comes with a PHP CLI called artisan. What is your favorite artisan command?
My favorite artisan command is php artisan make:model because it generates model classes quickly and easily.
3.Give us an example of Vue created() and mounted() as you applied it in your last app. Do explain why this was set up this way.
created() {
    // Perform initialization tasks here
    this.fetchData();
},
mounted() {
    // DOM has been mounted, perform tasks that require access to the DOM here
    this.setupListeners();
}

In this example, created() is used for initializing data or making API requests, while mounted() is used for DOM manipulation or setting up event listeners. This separation ensures that data is available before rendering and DOM-related tasks are performed after the component is mounted.

4. Form Validation - How do I validate a zip Dutch code / email address / password w 15 chars, at least one lower, upper case letter, one special char and one number?
To validate a Dutch zip code, email address, or password in Laravel, you can use Laravel's validation rules:
$validatedData = $request->validate([
    'zip_code' => 'required|regex:/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/',
    'email' => 'required|email',
    'password' => 'required|min:15|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{15,}$/',
]);

5. SEO issues in SPA - How do you deal with this with Vue routing to register users with Google Analytics?
To address SEO issues in a Single Page Application (SPA) with Vue routing, you can use server-side rendering (SSR) or prerendering techniques to generate static HTML content for search engine crawlers. You can also implement dynamic meta tags and sitemap generation to improve search engine visibility.
6. When registering a tablet or mobile as a quest to your application what can you find out about the device with server side code and what with frontend code? What plugins and or packages do you recommend?
With server-side code, you can detect device information such as user agent, screen size, and IP address using libraries like Mobile-Detect. With frontend code, you can use JavaScript libraries like platform.js to access device information such as device type, OS, and browser.
7 .Vue Key Modifier - give an example of one used in one of your projects
<template>
    <div v-for="item in items" :key="item.id">
        <span @click="deleteItem(item.id)" v-key:enter="deleteItem(item.id)">Delete</span>
    </div>
</template>
<script>
export default {
    data() {
        return {
            items: []
        };
    },
    methods: {
        deleteItem(id) {
            // Delete item logic
        }
    }
};
</script>

In this example, v-key:enter is a custom Vue key modifier that listens for the Enter key press to trigger the deleteItem method.
8.Below line of code,
Route::group(['prefix' => 'dashboard', 'middleware' => ['auth', 'subcheck'], 'namespace' => 'Dashboard'], function () {
do for routes included in that code part in web.php? What is a prefix for? What is a group in this case?
Route group explanation and usage:
The prefix is used to define a common route prefix for all routes inside the group, making it easier to organize and group related routes.
The middleware array specifies middleware that should be applied to all routes in the group.
The namespace is used to define the namespace for controller classes within the group.

9. You need to add add a new private checkbox (private or not) to the dashboard for a site. Checked site will be private. How would you go about adding this new option to the dashboard and storing it to an existing database table?
Add a new column in the existing database table to store the checkbox value.
Update the dashboard UI to include the new checkbox.
Modify the controller to handle the checkbox value when saving/updating data.
Update any validation rules or form requests to validate the new checkbox field.
Standard Vue JS Issue:
 
10. [vue/no-use-v-if-with-v-for]

The 'textModules' variable inside 'v-for' directive should be replaced with a computed property that returns filtered array instead. You should not mix 'v-for' with 'v-if'.
Explain in plain English what this issue is and how you would resolve this.

This Vue issue advises against using v-if inside v-for directive to conditionally render elements. To resolve this, you should use a computed property to filter the array before rendering. For example:
computed: {
    filteredTextModules() {
        return this.textModules.filter(module => module.condition);
    }
}
Then, use v-for on the computed property instead of the original array.
 


Comments

Popular posts from this blog

MySQL's ACID compliance

Mysql acid compliance ACID is an acronym that stands for four key properties of database transactions: Atomicity Ensures that a transaction is treated as a single, indivisible unit of work Either all operations within a transaction are completed successfully, or none are If any part of the transaction fails, the entire transaction is rolled back to its previous state Prevents partial updates that could leave the database in an inconsistent state Consistency Guarantees that a transaction brings the database from one valid state to another valid state All data written to the database must adhere to defined rules, constraints, cascades, triggers, and other database integrity mechanisms Ensures that any transaction will not break the database's predefined rules Isolation Determines how and when changes made by one transaction become visible to other transactions Prevents interference between concurrent transactions MySQL provides different isolation levels: Read Uncommitted Read Commit...

PHP OOPs exercise - Basic Oops

  Here are key PHP OOP (Object-Oriented Programming) exercise questions with solutions: Basic Class and Object Exercise: // Create a simple bank account class class BankAccount {     private $accountNumber;     private $balance;     public function __construct($accountNumber, $initialBalance = 0) {         $this->accountNumber = $accountNumber;         $this->balance = $initialBalance;     }     public function deposit($amount) {         if ($amount > 0) {             $this->balance += $amount;             return true;         }         return false;  ...

Interview questions for Senior PHP Developer particle41.com

1.Self Introduction 2.Basic questions on session and cookie. 3.Where is session stored? 4.Difference between Cookie and session. 5.Will there be any session before session start? 6.Post Max execution time.How can we modify it? 7.We have a string, "BJFSJK".Without any php function reverse it with half the string length.   To reverse the string with half the string length without using any PHP functions, you can implement a simple algorithm to achieve the desired result. Here's how you can do it: Initialize two pointers, one at the beginning of the string and the other at the midpoint of the string. Swap characters between these two pointers iteratively, moving the pointers towards each other until they meet or cross each other. Here's the PHP code to implement this algorithm:  <?php $string = "ABC100"; $length = strlen($string); // Calculate the midpoint of the string $midpoint = (int)($length / 2); // Initialize pointers $start = 0; $end = $length - 1; //...