diff src/Generator/Model/stubs/model.stub @ 34:f65ab84ee47f default

merge with codex
author luka
date Wed, 10 Sep 2025 21:00:47 -0400
parents 8dd668020310
children 76584181267a
line wrap: on
line diff
--- a/src/Generator/Model/stubs/model.stub	Sat Dec 02 10:20:32 2023 -0500
+++ b/src/Generator/Model/stubs/model.stub	Wed Sep 10 21:00:47 2025 -0400
@@ -2,11 +2,10 @@
 
 namespace {{ namespace }};
 
-use Illuminate\Database\Eloquent\Factories\HasFactory;
-use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\SoftDeletes;
+use Wizard\Framework\Models\BaseModel;
 
-class {{ class }} extends Model
+class {{ class }} extends BaseModel
 {
     //use HasFactory;
     use SoftDeletes;
@@ -27,17 +26,67 @@
 			# {{ atributeInsertPoint }}
     ];
 
+		protected $casts = [
+			# {{ castInsertPoint }}
+		];
 
-		public static function boot() : void {
-			parent::boot();
+		protected $fillable = [
+			# {{ fillableInsertPoint }}
+		];
+
+		protected $default_relations = [
+			# {{ defaultRelationsInsertPoint }}
+		];
+
+		protected static $filters = [
+			# {{ defaultFiltersInsertPoint }}
+		];
+
+		public static function get_filters() {
+			return static::filters;
+		}
+
+		//relations
+
+		// BelongsTo
+		# {{ belongs_to_relationships }}
+
+		// HasMany
+		# {{ has_many_relationships }}
+		
+    // HasManyThrough
+		# {{ has_many_through_relationships }}
+
 
-			self::creating(function ($item) {
-				$item->created_by = \Auth::user()->id;
-				$item->updated_by = \Auth::user()->id;
-			});
+		/**
+		 * Load the default relations for the model.
+		 *
+		 * @return $this
+		 */
+		public function load_relations() {
+			foreach($this->default_relations as $relation) {
+				$this->load($relation);
+			}
+			return $this;
+		}
 
-			self::saving(function ($item) {
-				$item->updated_by = \Auth::user()->id;
-			});
+		/**
+		 * Retrieve a query builder instance with default relations loaded.
+		 *
+		 * @return \Illuminate\Database\Eloquent\Builder
+		 */
+		public static function data_query() {
+			return parent::data_query();
 		}
+
+		/**
+     * Retrieve a query builder instance with default relations loaded.
+     *
+     * @return \Illuminate\Database\Eloquent\Builder
+     */
+    public static function get_data(array $validated = [])
+    {
+        return parent::get_data($validated);
+    }
+
 }