Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
Laravel project settings by environment
Local environment settings:
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
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Both ID Name URL support
Both ID and Name of the record is supported with GET URL
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']);
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Makes the array member stay filled after backend validation is failed
Makes the array member stay filled if the form is not successfully validated on the backend:
$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>
by Valeri Tandilashvili
3 years ago
0
Laravel
0
Include .blade.php file
Includes
.blade.php
file located at:
\resources\views\external\calculator
<div class="container">
    
    @include('external.calculator.panel')

</div>
by Valeri Tandilashvili
3 years ago
0
Laravel
0
set identifier name to foreign key
When we have an Identifier name on the foreign key is a too-long error we can set name ourselves. Note:
Max foreign char size is 64
Example: Before:
$table->foreign('risk_project_id',)->references('id')->on('business_risk_projects')->onDelete('restrict');
Solution:
$table->foreign('risk_project_id', 
'business_rp_has_responsible_persons_risk_project_id_foreign'
)->references('id')->on('business_risk_projects')->onDelete('restrict');
Just add a second parameter to the foreign() method with the name of the key 
by Luka Tatarishvili
3 years ago
0
Laravel
0
If we have a table with a seeder and we want to add a foreign key to a column it must contain the correct id value or it can't be empty.
You can't use a value that doesn't belong to any entity in the other table nor delete one entity who has its ID in some other foreign_key in some other entity
by Luka Tatarishvili
3 years ago
0
Laravel
database
0
UTF-8 Unicode problem while json_encode()
JSON_UNESCAPED_UNICODE Json:
"[{"name":"additional[text][9]","value":"\u10e1 \u10d3\u10d0\u10e1\u10d0\u10d1\u10e3\u10d7\u10d4\u10d1\u10d0 (Judgement process"},{"name":"additional[text][3]","value":"version"}]"
If our json contains something like this
\u10d3\u10d0\u10e1\u10d0\u10d1\u10e3\u10d7\u10d4\u10d1\u10d0
we have UTF-8 unicode problem.
JSON_UNESCAPED_UNICODE
fixes this problem, so we can encode json like this
json_encode($request->field_data, JSON_UNESCAPED_UNICODE)
by Luka Tatarishvili
3 years ago
0
JSON
Laravel
DBquery
0
Sort array of arrays by sub-array values
We need to sort the array by
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);
by Valeri Tandilashvili
3 years ago
0
PHP
0
Delete binary logs
Deletes binary logs created before the specified date
purge binary logs before ‘2022-03-03’;
by Valeri Tandilashvili
3 years ago
0
MySQL
0
File & folder sizes
Shows files and folders with their sizes in the current directory
du -h --max-depth=1
by Valeri Tandilashvili
3 years ago
0
Linux
0
Results: 1578