REPLACE
statement updates the listed columns if primary key (one of the listed columns) already exists. Otherwise inserts as a new recordREPLACE INTO students (id, first_name, points)
VALUES (41, 'ილიკო', 147)
Similar to the REPLACE INTO
statement is ON DUPLICATE KEY
.
The only difference is that on duplicate key it updates only the listed columns but omitted values stays the sameINSERT INTO students (id, first_name, points)
VALUES (41, 'გიორგი', 149)
ON DUPLICATE KEY
UPDATE first_name = 'გიორგი', points = 123
Note 1
: If primary key is not listed, it will insert the record, but if the primary key is one of the listed columns, it will update the specified row that matches the primary key.
Note 2
: If the primary key exists, all the other omitted columns will get the default values after updating the record.php artisan make:component ComponentName
creates ComponentName.blade.php
inside resources/view/components
and controller ComponentName.php
inside App\View\Component
directory
you can render component by x-
syntax <x-component-name />
pass variables to components
use var-name=
for normal strings and use :var-name=
for variables
<x-component-name var-name="normal string" :var-name2="$some_variable"/>
make sure to use kebab-case
as html attribute names and camelCase
inside constructor argument
and inside component controller file ComponentName.php
namespace App\View\Components;
use Illuminate\View\Component;
class ComponentName extends Component
{
public $varName1;
public $varName2;
public function __construct($varName1, $varName2)
{
$this->varName1 = $varName1;
$this->varName2 = $varName2;
}
public function customFunction($last)
{
return [1, 2, 3, 4, 5, 6, 7, $last]; // or data from db for example
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|\Closure|string
*/
public function render()
{
return view('components.component_name');
}
}
inside ComponentName.blade.php
we can retrieve these variables like so
<div class="component-class">
<div>{{$varName1}}</div>
<div>{{$varName2}}</div>
@foreach($customFunction('last line') as $line)
<h1>{{$line}}</h1>
@endforeach
</div>
PI
radians 1.5707963267948966
converted to degrees gives us 90
degrees.
PI
: 3.141592653589793
radians converted to degrees gives us 180
degrees.SELECT
DEGREES(1.5707963267948966),
DEGREES(3.141592653589793)
const taskArrays = ['code', 'Eat', 'code'];
console.log(taskArrays);
//["code", "Eat", "code"]
Use when you need ordered
list of values (might contains duplicates)
Use when you need to manipulate
data
const taskSets = new Set(['code', 'Eat', 'code']);
console.log(taskSets);
//{"code", "Eat"}
Use when you need to work with unique
values
Use when High-performance
is really important
Use to remove
duplicates from arraysObject
const taskObjects = {
task: 'code',
date: 'today',
repeat: true
}
console .log(taskObjects)
//{task: "code", date: "today", repeat: true}
More "traditional" key/value
Easier to write and access values with . and [ ]
Use when you need to include Functions
(methods)
Use when working with JSON (can convert to map)
Maps
const taskMaps = new Map( [
['task', 'code'],
['date', 'today'],
[false, 'start coding!'],
]);
console .log(taskMaps)
//{"task" => "code", "date" => "today", false => "start coding!"}
Better performance
Keys can have any data type
Easy to iterate
Easy to compute size
Use when you simply need to map key to values
Use when you need key that are not
strings