aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2026-02-09 10:56:55 -0800
committerGravatar Tom Willemse2026-02-09 10:56:55 -0800
commit185ffdf4e30c816313eeefdbf9f0ca7dfff4c255 (patch)
tree22ee69a28cfe87df430c379cd679daae1c001240
parentab8f419f60beef6da9664f4d27df27fa167a5bbd (diff)
downloadnew-dotfiles-185ffdf4e30c816313eeefdbf9f0ca7dfff4c255.tar.gz
new-dotfiles-185ffdf4e30c816313eeefdbf9f0ca7dfff4c255.zip
pop-os/emacs: Add function to make filament forms
-rw-r--r--oni/home/config/pop-os/emacs.el47
1 files changed, 41 insertions, 6 deletions
diff --git a/oni/home/config/pop-os/emacs.el b/oni/home/config/pop-os/emacs.el
index 24a48d6..c4aa16e 100644
--- a/oni/home/config/pop-os/emacs.el
+++ b/oni/home/config/pop-os/emacs.el
@@ -57,7 +57,8 @@
;; ("t" "Test" artisan-test-transient)
("mm" "Make Migration" artisan-make-migration-transient)
("mM" "Make Model" artisan-make-model-transient)
- ("mf" "Make Factory" artisan-make-factory-transient)])
+ ("mf" "Make Factory" artisan-make-factory-transient)
+ ("mFf" "Make Filament Form" artisan-make-filament-form-transient)])
(defun artisan-punt-composer-install ()
(interactive)
@@ -189,6 +190,8 @@ Optional argument STOPP means stop on any defect."
:file file
:stop-on-failure-p stopp)))
+(autoload 'which-function "which-func")
+
(defun artisan-run-test-at-point (name &optional stopp)
"Run PHP artisan test on the function NAME.
Optional argument STOPP means stop on any defect."
@@ -278,22 +281,54 @@ Optional argument STOPP means stop on any defect."
(transient-define-prefix artisan-make-model-transient ()
"Make model."
- ["Arguments & Switches"]
+ ["Arguments & Switches"
+ ("-f" "Factory" "--factory")
+ ("-m" "Migration" "--migration")]
["Commands"
("m" "Make" artisan-make-model)])
-(defun artisan-make-model (&optional name)
- (interactive "MName: ")
+(defun artisan-make-model (&optional name args)
+ (interactive
+ (list (read-string "Name: ")
+ (transient-args transient-current-command)))
(let* ((root (project-root (project-current)))
(default-directory (expand-file-name "chanced" root))
(bad-file-name (expand-file-name (format "chanced/app/%s.php" name) root))
- (good-file-name (expand-file-name (format "common/app/Models/%s.php" name) root)))
+ (good-file-name (expand-file-name (format "common/app/Models/%s.php" name) root))
+ (factoryp (transient-arg-value "--factory" args))
+ (migrationp (transient-arg-value "--migration" args)))
(shell-command
- (format "docker exec chanced-backend php artisan make:model %S" name))
+ (format "docker exec chanced-backend php artisan make:model %s %s -- %S"
+ (if factoryp "--factory" "")
+ (if migrationp "--migration" "")
+ name))
+ (when factoryp
+ (rename-file (expand-file-name (format "chanced/database/factories/%sFactory.php" name) root)
+ (expand-file-name "common/database/factories/" root))
+ (vc-register (cons 'Git (list (list (expand-file-name (format "common/database/factories/%sFactory.php" name) root))))))
+ (when migrationp
+ (rename-file (car (file-expand-wildcards
+ (expand-file-name (format "chanced/database/migrations/*_create%s*_table.php"
+ (let ((case-fold-search nil))
+ (replace-regexp-in-string
+ (rx (group (any (?A . ?Z))))
+ (lambda (match) (concat "_" (downcase match)))
+ name t)))
+ root)))
+ (expand-file-name "common/database/migrations/" root))
+ (vc-register (cons 'Git (list (list (car (file-expand-wildcards
+ (expand-file-name (format "common/database/migrations/*_create%s*_table.php"
+ (let ((case-fold-search nil))
+ (replace-regexp-in-string
+ (rx (group (any (?A . ?Z))))
+ (lambda (match) (concat "_" (downcase match)))
+ name t)))
+ root))))))))
(rename-file bad-file-name good-file-name)
(find-file good-file-name)
(save-excursion
+ (goto-char (point-min))
(search-forward "namespace App;")
(kill-whole-line)
(insert "namespace App\\Models;\n")