Answers for "update db laravel"

PHP
0

laravel db::query update

DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));
Posted by: Guest on November-19-2020
4

TRANSACTON LARAVEL QUERY BUILDER

DB::beginTransaction();

try {
    DB::insert(...);    
    DB::commit();
} catch (\Throwable $e) {
    DB::rollback();
    throw $e;
}
Posted by: Guest on September-22-2020
2

laravel join

$latestPosts = DB::table('posts')
                   ->select('user_id', DB::raw('MAX(created_at) as last_post_created_at'))
                   ->where('is_published', true)
                   ->groupBy('user_id');

$users = DB::table('users')
        ->joinSub($latestPosts, 'latest_posts', function ($join) {
            $join->on('users.id', '=', 'latest_posts.user_id');
        })->get();
Posted by: Guest on August-13-2020

Browse Popular Code Answers by Language