component load based on category value change in vuejs

 To load a different component based on a change in category value in Vue.js, you can use the computed property to return the appropriate component based on the selected category value.

Here's an example code snippet:

<template> <div> <select v-model="selectedCategory"> <option v-for="category in categories" :key="category" :value="category"> {{ category }} </option> </select> <component :is="currentComponent"></component> </div> </template> <script> import Component1 from './Component1.vue'; import Component2 from './Component2.vue'; import Component3 from './Component3.vue'; export default { components: { Component1, Component2, Component3, }, data() { return { selectedCategory: 'Category 1', categories: ['Category 1', 'Category 2', 'Category 3'], }; }, computed: { currentComponent() { if (this.selectedCategory === 'Category 1') { return 'component1'; } else if (this.selectedCategory === 'Category 2') { return 'component2'; } else if (this.selectedCategory === 'Category 3') { return 'component3'; } else { return 'component1'; } }, }, }; </script>

In this example, we have a select element that allows the user to choose a category. We use v-for to loop through the categories array and display each category as an option in the select element.

We use the component element to dynamically display the current component based on the selected category value. We use the :is attribute to bind the component to the currentComponent computed property.

We import the components (Component1, Component2, and Component3) at the top of our Vue component and register them as local components using the components option.

We use the computed property to return the appropriate component based on the selected category value. We use an if-else statement to check the value of the selectedCategory property and return the appropriate component name as a string.

Note that you can also use the watch option to monitor changes to the selectedCategory property and perform some actions based on the new value. However, using a computed property is generally a cleaner and more efficient way to dynamically display components based on a data property.


Read More

bootstrap-modal-show-only-once-per-visit

 https://webdev-il.blogspot.com/2019/06/bootstrap-modal-show-only-once-per-visit.html

Read More

3 Steps to learn Laravel Easily | Laravel Crud Operation with Authentication

 Laravel is a strong MVC PHP framework, designed for developers who need a simple and elegant toolkit to bring full- featured web operations. Laravel was created by Taylor Otwell.


This article will guide the developers who want to learn easily Laravel through some simple steps.

3 Steps to learn Laravel Easily:
Step 1: Download laravel and Authentication Screen Setup
Run the following command to download Laravel Latest Vesrion - 
  • composer create-project laravel/laravel project-laravel
Atfer running the above command laravel project will be Downloaded in htdocs folder (Xampp)/ www folder (Wamp). then go in your project folder and run the following two command one by one to setup laravel default Authentication - 
  • composer require laravel/ui
  • php artisan ui vue –auth
    Install Laravel Form Collective:
  •     composer require laravelcollective/html
Step 2: Connect Laravel Project to Database
In this tutorial I am going to use MySQL. So, at first I am going to create a Database "project_laravel". Then create two table name "users" and "subject" in this database.
Now go to your project folder and find .env file (located in your project root folder) and just open this file.


Replace the database name with your database name and user name keep as "root". That's it. Your are now successfully connected your project to MySql server.


Step 3: Create View, Model & Controller File.
  • Create Route in the web.php file
Route::resource('crud', 'App\Http\Controllers\SubjectController');
  • Create View File
go to project folder and create a blade file in resources>views. Suppose this blade file name "crud.blade.php". Data will be appends in this file.

Content of view file:
  • Create Model file
go to project folder and create a model file in app>Models. Suppose this Model file name "Subject.php". Subject related table entity and attribute will be defined here. model for users table will be automatically created while project downloaded. following command will generate the model file.
php artisan make:model Models\Subject

Content of Model file:



  • Create Controller file
go to project folder and create a model file in app>Http>Controllers. Suppose this Controller file name "SubjectController.php". crud related table entity and attribute will be defined here. Following command will generate the controller file.
php artisan make:controller SubjectController --resource

Content of Controller file:



Read More

What is Laravel?

Laravel is a strong MVC PHP framework, designed for developers who need a simple and elegant toolkit to bring full- featured web operations. Laravel was created by Taylor Otwell.

This article will guide the developers who want to learn how to develop a system using Laravel. This tutorial is particularly meant for all those developers who have no previous experience of using Laravel.

Prerequisites:

Before you start with Laravel, we consider that you are so much familiar with HTML, Core PHP, and Advance PHP. However, we suggest you to pick tutorials grounded on these concepts first, to gain a better understanding of Laravel, If you are new to any of these concepts.
Read More

Javascript - validation, numbers only

 jQuery('.decimal').on('keydown', function (event) {return isNumberOveride(event, this);});


function isNumberOveride(evt, element) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if ((charCode != 190 || $(element).val().indexOf('.') != -1) // “.” CHECK DOT, AND ONLY ONE.
&& (charCode != 110 || $(element).val().indexOf('.') != -1) // “.” CHECK DOT, AND ONLY ONE.
&& ((charCode < 48 && charCode != 8)
|| (charCode > 57 && charCode < 96)
|| charCode > 105))
return false;
return true;
}
Read More

Laravel - Login with username, email or phone with Status

 



Let's begin with the way to login with username or e mail in laravel 8/7/6 auth. i'm able to come up with easy answer of laravel 7/6 login with username or e mail in authentication. it is smooth to make auth login with username and e mail deal with in laravel 8/7/6 application.

Sometime, we want to create login web page with username or e mail deal with to login. it is super characteristic when you have on your internet site due to the fact it is virtually smooth to bear in mind every person for your purchaser. purchaser if forgot e mail then he has one username. So it is virtually helps.

In laravel 6, i'm able to deliver how you may setup for login with username or e mail step through step. so let's comply with bellow steps.

Step 1: Install Laravel 6

Initially we want to get clean Laravel 6 model utility the use of bellow command, So open your terminal OR command spark off and run bellow command:

composer create-project laravel/laravel example-app

Step 2: Install Laravel UI

You should observe few step to make auth for your laravel 6 utility.

At last go into project folder and open terminal then type and run the following command for running the project.

 php artisan serve

Then Create a Table named 'users'. 

3.create database and tbl users. insert user data

4.config .env file.

5. then run 

composer require laravel/ui

php artisan ui vue --auth

php artisan migrate



6. now project is ready.


7. install laravel collective.

composer require laravelcollective/html


Step 3: Generate Auth Scaffold


Here, we want to generate auth scaffolding in laravel 6 the use of laravel ui command. so, let's generate it via way of means of bellow command:


personal home page artisan ui bootstrap --auth

Now you want to run npm command, in any other case you cannot see higher format of login and sign in page.


Install NPM:


npm install


Run NPM:


npm run dev


Step 4: Add Username Column


Now upload new column username on your customers table, so that you can in reality replace your migration as like bellow.


migration


Now you could run migration


personal home page artisan migrate


Step 5: Update Login View


Laravel has created default login blade file. we want to feature comman username subject on it and cast off e mail subject. so let's replace like as bellow:


Just add field "username" and "status" in User Table.

Add these field name in User Model.

Make Change in Login Page "email" to "username" and type="email" to type="text"

then edit LoginController.php

add 

use Illuminate\Http\Request;

then add 

public function username()

    {

        return "username";

    }


    /**

     * Get the needed authorization credentials from the request.

     *

     * @param  \Illuminate\Http\Request  $request

     * @return array

     */

    protected function credentials(Request $request)

    {

        //return $request->only($this->username(), 'password');

        return ['username'=>$request->{$this->username()},'password'=>$request->password,'status'=>'1'];

    }


File should be like this:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;

use App\Providers\RouteServiceProvider;

use Illuminate\Foundation\Auth\AuthenticatesUsers;

use Illuminate\Http\Request;

class LoginController extends Controller

{

    /*

    |--------------------------------------------------------------------------

    | Login Controller

    |--------------------------------------------------------------------------

    |

    | This controller handles authenticating users for the application and

    | redirecting them to your home screen. The controller uses a trait

    | to conveniently provide its functionality to your applications.

    |

    */


    use AuthenticatesUsers;


    /**

     * Where to redirect users after login.

     *

     * @var string

     */

    protected $redirectTo = RouteServiceProvider::HOME;


    /**

     * Create a new controller instance.

     *

     * @return void

     */

    public function __construct()

    {

        $this->middleware('guest')->except('logout');

    }


    public function username()

    {

        return "username";

    }


    /**

     * Get the needed authorization credentials from the request.

     *

     * @param  \Illuminate\Http\Request  $request

     * @return array

     */

    protected function credentials(Request $request)

    {

        //return $request->only($this->username(), 'password');

        return ['username'=>$request->{$this->username()},'password'=>$request->password,'status'=>'1'];

    }

}

Thats it. 

Read More

Litebox Image Gallery Using PHP

 <?php

include("header.php");

?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/css/lightbox.css">

<style> 

#imgTest:hover{

box-shadow: 0px 0px 10px 2px rgba(0,0,0,1);

}

</style>

      <!-- Breadcromb Area Start -->

      <section class="gauto-breadcromb-area section_70">

         <div class="container">

            <div class="row">

               <div class="col-md-12">

                  <div class="breadcromb-box">

                     <h3>Gallery</h3>

                     <ul>

                        <li><i class="fa fa-home"></i></li>

                        <li><a href="index.php">Home</a></li>

                        <li><i class="fa fa-angle-right"></i></li>

                        <li>Gallery</li>

                     </ul>

                  </div>

               </div>

            </div>

         </div>

      </section>

      <!-- Breadcromb Area End -->





      <!-- About Page Area Start -->

      <section class="about-page-area section_70" style="background-color: white;">

         <div class="container">

         

            <div class="row">

            <?php

            $sl = 1;

$get = mysql_query("SELECT * FROM `gallery` ORDER BY `i_id` DESC ");

while($data = mysql_fetch_array($get)){

?>

                <div class="col-lg-3">

                  <div class="about-page-left">

    <a class="example-image-link" href="images/<?php echo $data["i_image"];?>" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img id="imgTest" class="example-image img-thumbnail" src="images/<?php echo $data["i_image"];?>" alt="" style="width:230px; height:180px; margin:10px;"/></a>

                  </div>

                </div>

                <?php

                //$sl++;

            }

            ?>

            </div>

            

         </div>

      </section>

      <!-- About Page Area End -->

       



<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/js/lightbox.js"></script>


<?php

include("footer.php");

?>


Read More

The 27 Most Useful PHP Array Functions.

Now, we know What is Array in PHP? and how it work in PHP. After creating an array we need to  count values in array, sort arrays by their contents, convert them between strings and arrays, find unique values, search within arrays, compare arrays to other arrays and more. 

By using array functions we can easily access and manipulate an array. In following I am going to describe array function with example.

Note that the following array function is mostly used in PHP array to access and manipulate the arrays.

  • is_array():

This function is used to find whether a variable is an array or not.

Syntax:

is_array($variable_name);

Example 1:

<?php 
$array=array('x','y','z'); 
if (is_array($array)){ 
echo 'Yes! It is an array.'; 
}else{
echo 'No! It is not an array.';
?>

Output of the above program:
Yes! It is an array.

Example 2:

<?php 
$mark = [ 
'id' => 1027, 
'name' => 'John Abhram', 
'class' => 'Class ten', 
[ 'gender' => 'male', 
  [ 
    'bangla' => '100', 
    'english' => '95', 
    'mathematics' => '85' 
  ], 
   'country' => 'bangladesh' 
 ] 
]; 

$array1 = is_array($mark); 
$array2 = is_array($mark['roll']); 
$array3 = is_array($mark[0]); 

echo $array1 ? 'The $mark variable is an array<br>' : 'The $mark variable is not an array<br>'; 
echo $array2 ? 'The "id" key of the $mark variable is an array<br>' : 'The "id" key of the $mark variable is not an array<br>'; 
echo $array3 ? 'The 0 index of the $mark variable is an array<br>' : 'The 0 index of the $mark variable is not an array<br>'; 
?>

Output of the above program:

The $mark variable is an array<br>
The "id" key of the $mark variable is not an array<br>
The 0 index of the $mark variable is an array<br>


  • in_array():


This function searches in an array for a specific value. It returns TRUE if this specific value is found in the array, or FALSE otherwise.



Syntax:

in_array($value,  $array);


Example :

<?php 
$subjects = array("English", "Mathematics", "Biology"); 
if (in_array("Mathematics", $subjects)) { 
echo "Subject Mathematics is exist"; 
if (in_array("Biology", $subjects)) { 
echo "Subject mathematics is exist"; 
?>

Output of the above program:
Subject Mathematics is exist


  • array_unique():

This function helps to remove duplicate values from an array. The first appearance will be kept when two or more array values are the same and the other will be removed.


Syntax:

array_unique($array);


Example :

<?php 
$subjects = array("array1" => "Bangla", "English", "array2" => "Bangla", "English", "Mathematics"); 
$result = array_unique($subjects); 
print_r($result); 
?>

Output of the above program:
Array ( [array1] => Bangla [0] => English [2] => Mathematics )


  • array_search():

This function search an array for a specific value and returns the key. It returns the key if the value found and false otherwise.



Syntax:

array_search($value, $array);


Example :

<?php 
$array = array("x"=>"Bangla","y"=>"Turorial","z"=>"Stars"); 
print_r(array_search("Turorial", $array)); 
?>

Output of the above program:
y


  • array_reverse():

This array function return an array in reverse order with this array elements.



Syntax:

array_reverse($array);


Example 1:

<?php 
$array = array("x"=>"Bangla","y"=>"Turorial","z"=>"Stars"); 
print_r(array_reverse($array)); 
?>

Output of the above program:
Array ( [z] => Stars [y] => Turorial [x] => Bangla )




Example 2:

$array = [ 
'PHP array functions', 
'What is an array', 
'Creating Shopping cart using PHP and MySQLI', 
'Laravel Tutorials', 
'PHP array function Tutorials'
];

$array1 = array_reverse($array);

foreach ($array1 as $key => $value) { 
echo $key . ' - ' . $value . '<br>'; 
}

Output of the above program:

0 – PHP array function Tutorials
1 – Laravel Tutorials
2 – Creating Shopping cart using PHP and MySQLI 
3 – What is an array
4 – PHP array functions




  • array_map(): 
This function send each value of an array to a function then multiply each value by itself and at last return an array with the new values.

Syntax:

array_map(myfunction, array1, array2, array3, ...)

Example 1:

<?php 
function myfunction($num) { 
return($num*$num); 
$array = array(2,3,4,5,6); 
print_r(array_map("myfunction",$array)); 
?>

Output of the above program:

Array ( 
[0] => 1 
[1] => 4 
[2] => 9 
[3] => 16 
[4] => 25 
)

  • array_diff(): 
This function compares one or more arrays and provides the values from one array, that are not present in any other arrays.

Syntax:

array_diff($arrayone, $arraytwo)

Example 1:

<?php 
$arrayone = [ 
'Google', 
'Microsoft', 
'Apple', 
'Acer', 
'Asus', 
'HP', 
'NOKIA', 
'Samsung', 
'SYMPHONY' 
]; 

$arraytwo = [ 
'Google', 
'Microsoft', 
'Apple', 
'Acer', 
'Asus', 
'HP', 
'NOKIA', 
'Samsung' 
]; 

$diff = array_diff($arrayone, $arraytwo); 

print_r($diff);


Output of the above program:

Array ( [8] => SYMPHONY )

Array Counting Functions:

There are some array functions those are related to counting values or dealing with numbers. We can count the number of values in an array and also return the maximum or minimum value and others useful operations.
  • count(): 
Using this function we can know how many values are presented in a array.

Syntax:

count($array);

Example 1:

<?php 
$a[0] = 1; 
$a[1] = 3; 
$a[2] = 5; 
$result = count($a); 
print($result); 
?>


Output of the above program:

3

Example 2:

$technology = [ 
'Google', 
'Microsoft', 
'ASUS', 
'GRAMEEN PHONE', 
'BANGLALINK', 
'Juniper', 
'ACER', 
'Samsung', 
'SYMPHONY' 
];


Output of the above program:

9

  • max(): 
This function finds the maximum value of an array.

Syntax:

max(array);.
or
max(value1, value2, ...);

Parameters:
array − The array with values. 
value1, value2 − The values to compare.

Example 1:

<?php 
echo (max(80, 75, 95, 100, 25, 65, 35)); 
?>


Output of the above program:

100

  • min(): 
This function finds the minimum value of an array.

Syntax:

min(array);.
or
max(value1, value2, ...);

Parameters:
array − The array with values. 
value1, value2 − The values to compare.

Example 1:

<?php 
echo (max(80, 75, 95, 100, 25, 65, 35)); 
?>


Output of the above program:

25

  • array_rand(): 
This function returns one or more random keys from an array.

Syntax:

array_rand(array, number).
Parameters:
array − The specific array. 
number − The number of random keys to return.

Example 1:

<?php 
$array = array("p"=>"Television","q"=>"Computer","r"=>"Radio"); 
print_r(array_rand($array)); 
?>

Output of the above program:
p

Example 2:

<?php 
$array = array("p"=>"Television","q"=>"Computer","r"=>"Radio"); 
print_r(array_rand($array, 2)); 
?>

Output of the above program:

Array ( 
[0] => p 
[1] => q 
)

  • array_count_values(): 
This function count all the values of an array.

Syntax:

array_count_values($array);

Example 1:

<?php
$a=array("Television","Radio","Radio","Television","Computer");
print_r(array_count_values($a));
?>

Output of the above program:
Array ( 
[Television] => 2 
[Radio] => 2 
[Computer] => 1 
)

PHP - Sort Functions For Arrays:

  • sort():
This function sort arrays in ascending order.


Syntax:

sort($array);

Example 1:

<?php 
$people = array("American", "China", "Indian"); 
sort($people); 

$array_length = count($people); 

for($i = 0; $x < $array_length; $i++) { 
echo $people[$i]; 
echo "<br>"; 

?>

Output of the above program:
American
China
Indian

  • rsort():
This function sort arrays in descending order.


Syntax:

rsort($array);

Example 1:

<?php 
$people = array("American", "China", "Indian"); 
rsort($people); 

$array_length = count($people); 

for($i = 0; $x < $array_length; $i++) { 
echo $people[$i]; 
echo "<br>"; 

?>

Output of the above program:

Indian
China
American

  • asort():

This function sort associative arrays in ascending order, according to the value.

Syntax:

asort($array);

Example 1:

<?php 
$prices = array("Computer"=>"35k", "Laptop"=>"37k", "Radio"=>"2k"); 
asort($prices); 

foreach($prices as $key => $value) { 
echo "Key=" . $key . ", Value=" . $value
echo "<br>"; 

?>

Output of the above program:

Key=Computer, Value=35k
Key=Laptop, Value=37k
Key=Radio, Value=2k

  • ksort():

This function sort associative arrays in ascending order, according to the key.

Syntax:

ksort($array);

Example 1:

<?php 
$prices = array("Computer"=>"35k", "Laptop"=>"37k", "Radio"=>"2k"); 
ksort($prices); 

foreach($prices as $key => $value) { 
echo "Key=" . $key . ", Value=" . $value
echo "<br>"; 

?>

Output of the above program:

Key=Radio, Value=2k 
Key=Computer, Value=35k 
Key=Laptop, Value=37k

  • arsort():

This function sort associative arrays in ascending order, according to the key.

Syntax:

arsort($array);

Example 1:

<?php 
$prices = array("Computer"=>"35k", "Laptop"=>"37k", "Radio"=>"2k"); 
arsort($prices); 

foreach($prices as $key => $value) { 
echo "Key=" . $key . ", Value=" . $value
echo "<br>"; 

?>

Output of the above program:

Key=Laptop, Value=37k
Key=Computer, Value=35k
Key=Radio, Value=2k

  • krsort():

This function sort associative arrays in descending order, according to the key.

Syntax:

krsort($array);

Example 1:

<?php 
$prices = array("Computer"=>"35k", "Laptop"=>"37k", "Radio"=>"2k"); 
arsort($prices); 

foreach($prices as $key => $value) { 
echo "Key=" . $key . ", Value=" . $value
echo "<br>"; 

?>

Output of the above program:

Key=Radio, Value=2k 
Key=Laptop, Value=37k 
Key=Computer, Value=35k

Converting Between Arrays and Strings:

  • implode()
This function join array elements with a string.

Syntax:

implode(separator, $array);

Example 1:

<?php 
$array = array('Hello','world','This is Tutorial', 'Stars!'); 
echo implode(" ",$array); 
?>

Output of the above program:

Hello world This is Tutorial Stars!

  • explode()
This function break a string into an array.

Syntax:

explode(separator,string,limit)

Example 1:

<?php 
$array = "Hello world This is Tutorial Stars"; 
print_r (explode(" ",$array)); 
?>

Output of the above program:

Array ( 
[0] => Hello 
[1] => world 
[2] => This
[3] => is 
[4] => Tutorial
[5] => Stars 
)

General Manipulation Functions:

  • array_key_exists():
This function check if the key exists in an array.

Syntax:

array_key_exists(key, array)

Example 1:

<?php 
$array = array("laptop"=>"ASUS PRO BOOK","radio"=>"Radio 2"); 
if (array_key_exists("laptop",$array)) { 
echo "This key exists."; 
} else { 
echo "This key does not exist."; 

?>

Output of the above program:

This key exists.

  • array_keys():
This function is used to see all of the keys of the array, but not the values.


Syntax:

array_keys($array);

Example 1:

<?php 
$array = [ 'laptop'  => 'ASUS', 'television' => 'SONY', 'motherboard'    => 'GIGABYTE', ]; 
$arrayKeys = array_keys($array); 
print_r($arrayKeys);
?>

Output of the above program:

Array ( 
[0] => laptop 
[1] => television 
[2] => motherboard 
)

  • array_values():
This function is used to see all of the Values of the array, but not the Keys.


Syntax:

array_values($array);

Example 1:

<?php 
$array = [ 'laptop'  => 'ASUS', 'television' => 'SONY', 'motherboard'    => 'GIGABYTE', ]; 
$arrayValuues = array_values($array); 
print_r($arrayValuues);
?>

Output of the above program:

Array ( 
[0] => ASUS 
[1] => SONY 
[2] => GIGABYTE 
)

  • array_push():
This function is used to insert values at the end of an array.


Syntax:

array_push(array, value1, value2, ...);

Example 1:

<?php 
$array = array("Computer","Laptop"); 
array_push($array,"Radio","Television"); 
print_r($array); 
?>

Output of the above program:

Array ( 
[0] => Computer 
[1] => Laptop 
[2] => Radio 
[3] => Television 
)

  • array_pop():
This function is used to delete the last element of an array.


Syntax:

array_pop(array)

Example 1:

<?php 
$array = array("Computer","Laptop", "Radio"); 
array_pop($array); 
print_r($array); 
?>

Output of the above program:

Array ( 
[0] => Computer 
[1] => Laptop 
)

  • array_unshift():
This function is used to insert the new element to an array.


Syntax:

array_unshift(array, value1, value2, value3, ...);

Example 1:

<?php 
$array = array("p"=>"Computer","q"=>"Radio"); 
array_unshift($array,"Television"); 
print_r($array); 
?>

Output of the above program:

Array ( [0] => Television [p] => Computer [q] => Radio )

  • array_splice():
This function is used to remove elements from an array and replace it with new elements.


Syntax:

array_splice(array, start, length, array)

Example 1:

<?php 
$array1 = array("p"=>"Computer","q"=>"Laptop","r"=>"Radio","s"=>"Television"); 
$array2 = array("p"=>"Desktop","q"=>"Satteliate"); array_splice($array1,0,2,$array2); print_r($array1); 
?>

Output of the above program:

Array ( [0] => Desktop [1] => Satteliate [r] => Radio [s] => Television )

  • array_merge():
This function is used to merge two arrays into one array:.


Syntax:

array_merge($array1, $array2); 

Example 1:

<?php 
$array1 = [ 'Television', 'Radio', 'Satellite' ]; 
$array2 = [ 'Telegram', 'Tutorial', 'Stars' ]; 
$combine = array_merge($array1, $array2); 
echo '<pre>'; 
print_r($combine); 
?>

Output of the above program:

Array ( 
[0] => Television 
[1] => Radio
[2] => Satellite
[3] => Telegram
[4] => Tutorial
[5] => Stars 
)



Read More