Results: 1024
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']);
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
Install Certbot and it’s Nginx plugin with apt:
sudo apt install certbot python3-certbot-nginx
Verifies the syntax of your configuration edits:
sudo nginx -t
Reload Nginx to load the new configuration:
sudo systemctl reload nginx
To see the current setting of firewall:
sudo ufw status
Allows the Nginx Full profile and delete the redundant Nginx HTTP profile allowance:
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
Obtaining an SSL Certificate
sudo certbot --nginx -d example.com
Verifying Certbot Auto-Renewal:
sudo systemctl status certbot.timer
To test the renewal process, you can do a dry run with
certbot
:
sudo certbot renew --dry-run
failed to open stream: Permission denied
fopen(/var/www/test.sdtokens.com/storage/app/public/images/mesk.webp): failed to open stream: Permission denied
Solution to the problem is running these commands to get the permissions
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

php artisan storage:link
number_format
The default
thousands_separator
is
,
which is 4th parameter. Without passing something else for the
thousands_separator
parameter, the
latency
was equal to
1,511.68525
The following PHP code caused problem in MySQL
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5);
MySQL error:
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'latency' at row 1
Solution to the problem is to specify the 4th parameter as an empty string
""
to get
latency
equal to
1511.68525
$this->latency = number_format(microtime(1)-$_SESSION['startTime'], 5, '.', '');
List cronjobs "crontab -l"
To list all cronjobs we simply run
crontab -l
command Cronjobs will be displayed without edit mode
Edit cronjobs "crontab -e"
First we open crontab to make changes to jobs by entering
crontab -e
command Then we activate edit mode by clicking
i
letter After editing we need to exit from edit mode by clicking
Esc
button Then we click
:wq
to save the changes
00 21 * * * php /var/www/html/services_cron/job_payments/index.php >> /var/log/job_payments.log 2>&1
By adding the line above, we tell
cronjob
to run the following file every day at
21:00
/var/www/html/services_cron/job_payments/index.php
And write output to the log file
/var/log/job_payments.log
Receive root permissions
To receive root permissions, we run the following command
sudo -i
Note: after running the above command, we need to enter the user's password
Basic authentication
Postman request
Authorization type: Basic Auth
Username: usr
Password: pwd
PHP cURL request
curl_setopt($ch, CURLOPT_USERPWD, "usr:pwd");
Function
LAST_DAY
takes date and returns the last date of the month. In the example the result is
28
because the year is not leap year
SELECT 
    LAST_DAY('2021-02-15')
Results: 1024