use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
if (Schema::hasColumn($table, 'deleted_at')){
Query 1
}else{
Query 2
}
This is useful if we use one query in multiple resources but there is some differences in table structure and we need to use this column in condition:
for example:
if (Schema::hasColumn($table, 'deleted_at')){
$query = "SELECT
$columns_str
-- c1.order_priority,
(
SELECT
Count(c2.id)
FROM
$table AS c2
WHERE
c2.parent_id = c1.id
)
AS children_count
FROM
$table AS c1
WHERE deleted_at IS NULL
ORDER BY ".($order_priority ? 'order_priority' : 'id')." DESC";
}else{
$query = "SELECT
$columns_str
-- c1.order_priority,
(
SELECT
Count(c2.id)
FROM
$table AS c2
WHERE
c2.parent_id = c1.id
)
AS children_count
FROM
$table AS c1
ORDER BY ".($order_priority ? 'order_priority' : 'id')." DESC";
}
We use WHERE deleted_at IS NULL
where we have deleted_at columnimport pyautogui
import time
msg = input("message: ")
n = input("amount of msg : ")
count = 5
while(count != 0):
print(count)
time.sleep(1)
count -= 1
print("Fire in the hole")
for i in range(0,int(n)):
time.sleep(0.2)
pyautogui.typewrite(msg + '\n')
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 toolspublic 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']);
$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>
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
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
"[{"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)
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);