Showing 1-10 of 10 items.
Truy vấn dữ liệu từ Database trong Laravel
Eloquent ORM và Query Builder
WHAT?
Eloquent ORM đi kèm với Laravel cung cấp ActiveRecord đầy đủ và đơn giản để làm việc với database. Mỗi bảng của database sẽ được ánh xạ qua ‘Model’, và model này được sử dụng để tương tác với bảng.
Query Builder giúp chúng ta tạo những truy vấn từ database, có thể được sử dụng để thực thi hầu hết những thao tác về database trong ứng dụng và làm việc...
Code Laravel chuẩn
Sử dụng Laravel Eloquent withSum() and withCount()
Bài viết này mình sẽ giới thiệu các bạn cách sử dụng withSum() and withCount() với laravel relationship eloquent.
Để demo ví dụ mình sẽ tạo 2 tables là Category và Product và tạo relationship cho chúng.
Bạn có thể sử dụng withSum() & withCount() với laravel 6, laravel 7 & laravel 8 version.
Hãy xem ví dụ bên dưới nhé:
Category Model:
<?php
namespace App\Models;
use...
Code Laravel chuẩn
20 tips xử lý dữ liệu với Eloquent trong laravel
1. Increments and Decrements
Article::find($article_id)->increment('read_count');
Article::find($article_id)->increment('read_count', 10); // +10
Product::find($produce_id)->decrement('stock'); // -1
2. XorY methods
findOrFail
$user = User::findOrFail($id);
firstOrCreate()
$user = User::firstOrCreate(['email' => $email]);
3.Model boot() method
public static function boot()
{
parent::boot();
static::saving(function ($model) {
// do some...
Code Laravel chuẩn
Random articles
WHAT DO YOU THINK ABOUT FOOD DELIVERY BUSINESS?
Today’s entrepreneurs and owners start a business with on-demand food delivery apps. This is moving a successful path. Even the customers get core benefits just simply at home.
In the smartest world, people are using smartphones. With this smartphone, people can download many apps like social media apps, Netflix, Amazon, Flipkart, and even food delivery apps like UberEats Clone.
These are the things mostly used. According to eMarketer research, 23.8% of US smartphones will use for food...
ubereatsclone
ubereatsclonescript
ubereatscloneapp
foodregime
coderegime
1391
Dấu thời gian - Lưu trữ điện tử
1. Ký số đóng dấu thời gian là gì?
Dấu thời gian là dữ liệu điện tử gắn thông tin về ngày, tháng, năm và thời gian vào thông điệp dữ liệu, được cung cấp bởi một tổ chức cung cấp dịch vụ cấp dấu thời gian tin cậy.
Dấu thời gian sử dụng để làm bằng chứng và xác thực sự tồn tại của dữ liệu tại một mốc thời gian nhất định. Tài liệu, hồ sơ, thông điệp điện tử khi...
savis
ký số
dấu thời gian
timestamp
Lưu trữ
1013
Asset Pipeline là cái chi chi?
Asset Pipeline
Asset pipeline là cái chi chi?
Asset pipeline phụ trách công việc chính là: ghép lại (Concatenation) và giảm thiểu (Minification) hoặc nén (Compress) các tập tin Javascript, CSS.
Giải thích:
Sự ghép lại - Concatenation: Ghép nhiều tập tin thành một tập tin.
Giảm thiểu - Minification: quá trình loại bỏ tất cả các ký tự không cần thiết khỏi mã nguồn của ngôn ngữ lập trình được thông dịch hoặc...
basicrubyonrails
Beginner
RubyonRails
2511
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.