mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	build version 400
This commit is contained in:
		
							
								
								
									
										37
									
								
								app/Models/Setting.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/Models/Setting.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| <?php | ||||
| namespace Crater\Models; | ||||
|  | ||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
|  | ||||
| class Setting extends Model | ||||
| { | ||||
|     use HasFactory; | ||||
|  | ||||
|     public static function setSetting($key, $setting) | ||||
|     { | ||||
|         $old = self::whereOption($key)->first(); | ||||
|  | ||||
|         if ($old) { | ||||
|             $old->value = $setting; | ||||
|             $old->save(); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         $set = new Setting(); | ||||
|         $set->option = $key; | ||||
|         $set->value = $setting; | ||||
|         $set->save(); | ||||
|     } | ||||
|  | ||||
|     public static function getSetting($key) | ||||
|     { | ||||
|         $setting = static::whereOption($key)->first(); | ||||
|  | ||||
|         if ($setting) { | ||||
|             return $setting->value; | ||||
|         } else { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user