×
Clear all filters including search bar
Valeri Tandilashvili's Laravel Notes
php artisan route:list
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->mediumText('content');
$table->timestamps();
});
$table->id()
- creates bigint(20)
unsigned auto-increment field
$table->string('title')
- creates varchar(255)
utf8mb4_unicode_ci field
$table->mediumText('content')
- creates mediumtext
utf8mb4_unicode_ci field
$table->timestamps()
- creates created_at
and updated_at
timestamps.env
file contains database config information that needs to be changed
to use the databaseDB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=lara4db
DB_USERNAME=root
DB_PASSWORD=
ctrl + p
-> search ext install laravel blade
-> install laravel blade snippets
extensionphp artisan route:cache
This command will generate a cached version of our routes.
Once the routes are cached, Laravel
will use the cached version instead of parsing and compiling the routes on each request, which helps to improve the overall performance of your application
When we make changes to our routes, we need to regenerate it to reflect the updated routes
php artisan route:clear
This command will remove the cached routes, and the application will revert to parsing and compiling the routes dynamicallycomposer dump-autoload
php artisan cache:clear
php artisan config:clear
php artisan view:clear
/var/www/website.com/storage/logs/laravel.log
.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']);