Answers for "check exists in database when update laravel without id"

PHP
2

laravel db does not exists

if (DB::table('orders')->where('finalized', 1)->exists()) {
    // ...
}

if (DB::table('orders')->where('finalized', 1)->doesntExist()) {
    // ...
}
Posted by: Guest on August-14-2021
0

laravel migrate if not exists

if (!Schema::hasTable('tblCategory')) {
     Schema::create('tblCategory', function($table){
            $table->engine = 'InnoDB';
            $table->increments('CategoryID');
            $table->string('Category', 40);
            $table->unique('Category', 'tblCategory_UK_Category');
            $table->timestamps();
    }
}
Posted by: Guest on June-16-2021
1

laravel update if exists or create

$flight = App\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99]
);
Posted by: Guest on June-20-2021
1

laravel how to check if there are record exists

//User::  User is going to be what model you use.
//$user can be what ever you need it to be
$user = User::where('email', '=', Input::get('email'))->first();
if ($user != null) {
   // Record does exist
}
Posted by: Guest on February-22-2021

Code answers related to "check exists in database when update laravel without id"

Browse Popular Code Answers by Language