“banyak hal yang ada hubungan Laravel” Kode Jawaban

Situs WHERAS: https: //laravel.com/docs/

use Illuminate\Database\Eloquent\Builder;

// Retrieve posts with at least one comment containing words like code%...
$posts = Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'code%');
})->get();

// Retrieve posts with at least ten comments containing words like code%...
$posts = Post::whereHas('comments', function (Builder $query) {
    $query->where('content', 'like', 'code%');
}, '>=', 10)->get();
Tiago F2

model tabel pivot laravel

/*Model - Service*/
public function customer(){
    return $this->belongsToMany('customer')->withPivot(
        'start_date',
        'stop_date',
        'rem_date',
        'due_date',
        'status'
        );
}

/*Model - customer*/
public function services(){
    return $this->belongsToMany('Service')->withPivot(
        'start_date',
        'stop_date',
        'rem_date',
        'due_date',
        'status'
        );
}

////These following relations didnt workout
/*Model - custserv*/ //uses the pivot table customer_service//
public function staff(){
    return $this->belongsToMany('Staff');
}

/*Model - Staff*/
public function custservs(){
    return $this->belongsToMany('Custserv');
}

/*schema for pivot table 'staff' and 'Custserv' */
Schema::create('customer_service_user', function(Blueprint $table)
    {
        $table->increments('id');
        $table->integer('customer_service_id')->unsigned()->index();
        $table->foreign('customer_service_id')->references('id')->on('customer_service')->onDelete('cascade');
        $table->integer('staff_id')->unsigned()->index();
        $table->foreign('staff_id')->references('id')->on('staff')->onDelete('cascade');
        $table->timestamps();
    });
Hurt Hoopoe

banyak hal yang ada hubungan Laravel

use App\Models\User;

$user = User::find(1);

$user->roles()->attach($roleId);
Brainy Beetle

Jawaban yang mirip dengan “banyak hal yang ada hubungan Laravel”

Pertanyaan yang mirip dengan “banyak hal yang ada hubungan Laravel”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya