Current File : /home/tradevaly/demo.tradevaly.com.bd/app/Models/PackageBannerAd.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class PackageBannerAd extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $fillable = [
        'created_user_id', 'modified_user_id', 'deleted_user_id', 'name',  'type', 'status', 'updated_at'
    ];


    public function packageDetails()
    {
        return $this->hasMany('App\Models\PackageBannerAdDetail');
    }


    
    protected function getPackage($conditions  = [])
    {   
        $data = PackageBannerAd::where('status', 1)->where($conditions)->pluck('name', 'id')->toArray();

        return $data;
    }


    protected function getPackageWithDetails($conditions = [])
    {   
        //dd($conditions);
        $data = PackageBannerAd::where($conditions)
            ->with (['packageDetails' => function($mm){
                        return $mm->select('id', 'package_banner_ad_id', 'duration_id', 'price', 'description', 'status');
                }])->get()->toArray();

        return $data;
    }
}