init crater

This commit is contained in:
Mohit Panjwani
2019-11-11 12:16:00 +05:30
commit bdf2ba51d6
668 changed files with 158503 additions and 0 deletions

48
app/CompanySetting.php Normal file
View File

@ -0,0 +1,48 @@
<?php
namespace Laraspace;
use Illuminate\Database\Eloquent\Model;
use Laraspace\User;
class CompanySetting extends Model
{
protected $fillable = ['company_id', 'option', 'value'];
public function company()
{
return $this->belongsTo(Company::class);
}
public static function setSetting($key, $setting, $company_id)
{
$old = self::whereOption($key)->whereCompany($company_id)->first();
if ($old) {
$old->value = $setting;
$old->save();
return;
}
$set = new CompanySetting();
$set->option = $key;
$set->value = $setting;
$set->company_id = $company_id;
$set->save();
}
public static function getSetting($key, $company_id)
{
$setting = static::whereOption($key)->whereCompany($company_id)->first();
if ($setting) {
return $setting->value;
} else {
return null;
}
}
public function scopeWhereCompany($query, $company_id)
{
$query->where('company_id', $company_id);
}
}