×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
title
element from $xml
function value_in($element_name, $xml, $content_only = true) {
if ($xml == false) {
return false;
}
$found = preg_match('#<'.$element_name.'(?:\s+[^>]+)?>(.*?)'.
'</'.$element_name.'>#s', $xml, $matches);
if ($found != false) {
if ($content_only) {
return $matches[1]; //ignore the enclosing tags
} else {
return $matches[0]; //return the full pattern match
}
}
// No match found: return false.
return false;
}
$title = value_in('title', $xml);
dbname
except the two table: table1
and table2
mysqldump -u root -p --ignore-table=dbname.table1 --ignore-table=dbname.table2 dbname > dbname.sql
/var/www/website.com/storage/logs/laravel.log
du -h --max-depth=1
purge binary logs before ‘2022-03-03’;
price
value$inventory = array(
array("type"=>"fruit", "price"=>3.50),
array("type"=>"milk", "price"=>2.90),
array("type"=>"pork", "price"=>5.43),
);
The solution is to use array_multisort
function$price = array();
foreach ($inventory as $key => $row)
{
$price[$key] = $row['price'];
}
array_multisort($price, SORT_DESC, $inventory);
In PHP 5.5 or later array_column
function can be used$price = array_column($inventory, 'price');
array_multisort($price, SORT_DESC, $inventory);
.blade.php
file located at:\resources\views\external\calculator
<div class="container">
@include('external.calculator.panel')
</div>
$item_presale_tokens = old('values.0');
$item_liquidity_tokens = old('values.1');
Form html looks like this:<div class="form-group d-flex border-bottom-0">
<div class="form-equal-inputs">
<input type="number" step="1" min="1" value="{{ $item_presale_tokens }}" class="form-control {{ $errors->has('values.0') ? 'is-invalid' : '' }}" name="values[]" placeholder="Value"/>
</div>
</div>
<div class="form-group d-flex border-bottom-0">
<div class="form-equal-inputs">
<input type="number" step="1" min="1" value="{{ $item_liquidity_tokens }}" class="form-control {{ $errors->has('values.1') ? 'is-invalid' : '' }}" name="values[]" placeholder="Value"/>
</div>
</div>
public function showUpcomingProject($id){
if (intval($id)) {
$item = UpcomingProject::with('projectBlockchain')->findOrFail($id);
} else {
$item = UpcomingProject::with('projectBlockchain')->where('token_name', $id)->first();
}
if (!$item) {
return abort(404);
}
$blockchains = Blockchain::all();
return view(strtolower($this->title).'.home.upcoming_project', compact('item', 'blockchains'))->with('svg_renderer', SvgHelper::getBlockchainSvgs($blockchains));
}
If number is passed to the function as the record ID then if statement
will run.
If the token_name
is passed then else
will run.
If the record is not found, then 404
error is thrown to the client
Route Code for the feature: Route::get('/upcoming-projects/{id}', [ExternalController::class, 'showUpcomingProject']);
APP_ENV=local
APP_DEBUG=true
Test environment settings:APP_ENV=testing
APP_DEBUG=true
Production environment settings:APP_ENV=production
APP_DEBUG=false
The main difference is that errors are not shown on production, also prevention mechanisms from deleting DB data using migration tools