<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kanagama / laravel-eloquent-method-expansion example snippets
$users = DB::table('users')
->whereNameIsNull()
->get();
# select * from users where name IS NULL;
$users = DB::table('users')
->whereNameIsNotNull()
->get();
# select * from users where name IS NOT NULL;
$users = DB::table('users')
->whereTelEq('09099999999')
->get();
# select * from users where tel = '09099999999';
$users = DB::table('users')
->whereTelNotEq('09099999999')
->get();
# select * from users where tel <> '09099999999';
$users = DB::table('users')
->whereCreatedAtGt('1980-05-21')
->get();
# select * from users where created_at > '1980-05-21';
$users = DB::table('users')
->whereCreatedAtGte('1980-05-21')
->get();
# select * from users where created_at >= '1980-05-21';
$users = DB::table('users')
->whereModifiedAtLt('1980-05-21 00:00:00')
->get();
# select * from users where modified_at < '1980-05-21 00:00:00';
$users = DB::table('users')
->whereModifiedAtLte('1980-05-21 00:00:00')
->get();
# select * from users where modified_at <= '1980-05-21 00:00:00';
$users = DB::table('users')
->whereUserStatusIdIn([
'1','2','3',
])
->get();
# select * from users where user_status_id in (1, 2, 3);
$users = DB::table('users')
->whereUserStatusIdNotIn([
'1','2','3',
])
->get();
# select * from users where user_status_id not in (1, 2, 3);
$users = DB::table('users')
->whereAddressLike('沖縄県')
->get();
# select * from users where address like '%沖縄県%';
$users = DB::table('users')
->whereAddressNotLike('沖縄県')
->get();
# select * from users where address not like '%沖縄県%';
$users = DB::table('users')
->whereAddressLikePrefix('沖縄県')
->get();
# select * from users where address like '沖縄県%';
$users = DB::table('users')
->whereAddressNotLikePrefix('沖縄県')
->get();
# select * from users where address not like '沖縄県%';
$users = DB::table('users')
->whereAddressLikeBackword('沖縄県')
->get();
# select * from users where address like '%沖縄県';
$users = DB::table('users')
->whereAddressNotLikeBackword('沖縄県')
->get();
# select * from users where address not like '%沖縄県';
$users = DB::table('users')
->whereRentDatetimeDate('2022-12-02')
->get();
# select * from `products` where date(`rent_datetime`) = "2022-12-02"
$users = DB::table('users')
->whereRentDatetimeDateGt('2022-12-02')
->get();
# select * from `products` where date(`rent_datetime`) > "2022-12-12"
$users = DB::table('users')
->whereRentDatetimeDateGte('2022-12-02')
->get();
# select * from `products` where date(`rent_datetime`) >= "2022-12-12"
$users = DB::table('users')
->whereRentDatetimeDateLt('2022-12-02')
->get();
# select * from `products` where date(`rent_datetime`) < "2022-12-12"
$users = DB::table('users')
->whereRentDatetimeDateLte('2022-12-02')
->get();
# select * from `products` where date(`rent_datetime`) <= "2022-12-12"
$users = DB::table('users')
->whereRentDatetimeMonth('12')
->get();
# select * from `products` where month(`rent_datetime`) = "12"
$users = DB::table('users')
->whereRentDatetimeMonthGt('10')
->get();
# select * from `products` where month(`rent_datetime`) > "10"
$users = DB::table('users')
->whereRentDatetimeMonthGte('10')
->get();
# select * from `products` where month(`rent_datetime`) >= "10"
$users = DB::table('users')
->whereRentDatetimeMonthLt('10')
->get();
# select * from `products` where month(`rent_datetime`) < "10"
$users = DB::table('users')
->whereRentDatetimeMonthLte('10')
->get();
# select * from `products` where month(`rent_datetime`) <= "10"
$users = DB::table('users')
->whereRentDatetimeMonth('31')
->get();
# select * from `products` where day(`rent_datetime`) = "31"
$users = DB::table('users')
->whereRentDatetimeMonthGt('15')
->get();
# select * from `products` where day(`rent_datetime`) > "15"
$users = DB::table('users')
->whereRentDatetimeMonthGte('15')
->get();
# select * from `products` where day(`rent_datetime`) >= "15"
$users = DB::table('users')
->whereRentDatetimeMonthLt('15')
->get();
# select * from `products` where day(`rent_datetime`) < "15"
$users = DB::table('users')
->whereRentDatetimeMonthLte('15')
->get();
# select * from `products` where day(`rent_datetime`) <= "15"
$users = DB::table('users')
->whereRentDatetimeYear('2022')
->get();
# select * from `products` where year(`rent_datetime`) = "2022"
$users = DB::table('users')
->whereRentDatetimeYearGt('2022')
->get();
# select * from `products` where year(`rent_datetime`) > "2022"
$users = DB::table('users')
->whereRentDatetimeYearGte('2022')
->get();
# select * from `products` where year(`rent_datetime`) >= "2022"
$users = DB::table('users')
->whereRentDatetimeYearLt('2022')
->get();
# select * from `products` where year(`rent_datetime`) < "2022"
$users = DB::table('users')
->whereRentDatetimeYearLte('2022')
->get();
# select * from `products` where year(`rent_datetime`) <= "2022"
$users = DB::table('users')
->whereRentDatetimeTime('12:00:00')
->get();
# select * from `products` where time(`rent_datetime`) = "12:00:00"
$users = DB::table('users')
->whereRentDatetimeTimeGt('12:00:00')
->get();
# select * from `products` where time(`rent_datetime`) > "12:00:00"
$users = DB::table('users')
->whereRentDatetimeTimeGte('12:00:00')
->get();
# select * from `products` where time(`rent_datetime`) >= "12:00:00"
$users = DB::table('users')
->whereRentDatetimeTimeLt('12:00:00')
->get();
# select * from `products` where time(`rent_datetime`) < "12:00:00"
$users = DB::table('users')
->whereRentDatetimeTimeLte('12:00:00')
->get();
# select * from `products` where time(`rent_datetime`) <= "12:00:00"
$users = DB::table('users')
->whereRentDateColumn('return_date')
->get();
# select * from `products` where `rent_date` = `return_date`
$users = DB::table('users')
->whereRentDateColumnGt('return_date')
->get();
# select * from `products` where `rent_date` > `return_date`
$users = DB::table('users')
->whereRentDateColumnGte('return_date')
->get();
# select * from `products` where `rent_date` >= `return_date`
$users = DB::table('users')
->whereRentDateColumnLt('return_date')
->get();
# select * from `products` where `rent_date` < `return_date`
$users = DB::table('users')
->whereRentDateColumnLt('return_date')
->get();
# select * from `products` where `rent_date` <= `return_date`
$users = DB::table('users')
->whereCreatedAtBetween(['2022-12-01', '2022-12-10',])
->get();
# select * from users where created_at between '2022-12-01' AND '2022-12-10'
$users = DB::table('users')
->whereCreatedAtNotBetween(['2022-12-01', '2022-12-10',])
->get();
# select * from users where created_at not between '2022-12-01' AND '2022-12-10'