Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Create and Manage Databases in MySQL and MariaDB
To begin, sign into MySQL or MariaDB with the following command:
mysql -u root -p
create a database by typing the following command:
CREATE DATABASE new_database;
To view a list of the current databases that you have created, use the following command:
SHOW DATABASES;
by გიორგი ბაკაშვილი
4 years ago
0
Linux
MySQL
2
Laravel latest() and oldest() Eloquent
The latest and oldest methods allow you to easily order results by table column. By default, result will be ordered by the
created_at 
column. You will pass the column name that you wish to sort by using
orderBy 
method. new method latest() eloquent
public function getLatestRecord()
{
    $latests = User::latest()->get();
}
old method OrderBy with latest eloquent
public function getLatestRecord()
{
    $latests = \DB::table('users')->orderBy('created_at','desc')->get();
}
new method oldest() eloquent
public function getOldestRecord()
{
    $oldest = User::oldest()->get();
}
by გიორგი ბაკაშვილი
4 years ago
0
Laravel
2
Debug errors in Laravel
blade
file on each row
@if ($errors->any())
     @foreach ($errors->all() as $error)
         <div>{{$error}}</div>
     @endforeach
 @endif
by Valeri Tandilashvili
4 years ago
0
Laravel
Validation
2
$errors->has() and "is-invalid" related issue
$errors->has('accountable_id')
did not work
@if($errors->has('accountable_id'))
    <div class="invalid-feedback">
        <strong>{{ $errors->first('accountable_id') }}</strong>
    </div>
@endif
Until
is-invalid
class was specified
class="form-control {{ $errors->has('accountable_id') ? 'is-invalid' : '' }}"
The complete example
<div class="form-group">
    <label for="exampleSelect2">Accountable <span class="text-danger">*</span></label>
    <select class="form-control {{ $errors->has('accountable_id') ? 'is-invalid' : '' }}" id="accountable_id" name="accountable_id">
        <option value="">Select Accountable</option>
        @foreach($users as $accountable)
            <option value="{{ $accountable->id }}" {{ $accountable_id == $accountable->id ? 'selected' : '' }}>{{ $accountable->name }}</option>
        @endforeach
    </select>
    @if($errors->has('accountable_id'))
        <div class="invalid-feedback">
            <strong>{{ $errors->first('accountable_id') }}</strong>
        </div>
    @endif
</div>
by Valeri Tandilashvili
4 years ago
0
Laravel
validation
2
Create an array from variables and their values:

$firstname = "Peter";
$lastname = "Griffin";
$age = "41";

$result = compact("firstname", "lastname", "age");

print_r($result);
by გიორგი ბაკაშვილი
4 years ago
0
PHP
PHP official doc
2
Displaying Your Current Laravel Version
php artisan --version
`
by გიორგი ბაკაშვილი
4 years ago
0
Laravel
version
laravel official doc
2
check response time in milliseconds using environment variable
Tests that response time is below 100ms
pm.environment.set("allowedMilliseconds", 100);

pm.test("Response time is less than "+pm.environment.get("allowedMilliseconds")+"ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(pm.environment.get("allowedMilliseconds"));
});
by Valeri Tandilashvili
4 years ago
0
Postman
postman tests
2
Use a regular expression to do a case-insensitive search for "w3schools" in a string:
<?php
$str = "Visit W3Schools";
$pattern = "/w3schools/i";
echo preg_match($pattern, $str);
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
RegEx
PHP official doc
2
is_string()
<?php
$values = array(false, true, null, 'abc', '23', 23, '23.5', 23.5, '', ' ', '0', 0);
foreach ($values as $value) {
    echo "is_string(";
    var_export($value);
    echo ") = ";
    echo var_dump(is_string($value));
}
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Variable Handling
PHP official doc
2
Return the current time as a Unix timestamp, then format it to a date:
<?php
$t=time();
echo($t . "<br>");
echo(date("Y-m-d",$t));
?>
by გიორგი ბაკაშვილი
4 years ago
0
PHP
Date
PHP official doc
2
Results: 1580