简体   繁体   中英

How to fetch record from table based on post ip address in laravel using eloquent ORM

I am want to fetch record based on user post ip address. I am using eloquent ORM. in such case which format ip address should be stored in database.

$ip = '192.255.365.25';
$employee = Employee::find($ip);

not able to fetch full record for respective rows

find() used to retrieve a model by its primary key, you can use first() as below

$ip = '192.255.365.25';
$employee = Employee::where('ip', $ip)->first();

for more see documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM