485 |
486 |
487 |
489 |
490 |
491 |
493 | {$_['addNew']}
494 |
495 |
496 |
497 |
498 |
499 | @php
500 | /** @var $modelName \${$modelVariable} */
501 | @endphp
502 | @scope('cell_actions', \${$modelVariable})
503 |
504 |
505 |
506 |
507 | @endscope
508 |
509 |
510 | @if (\$isEditModalOpen)
511 |
512 |
513 |
514 | {$_['updateModalDescription']}
515 |
516 |
517 | {$formFields}
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 | @endif
528 |
529 |
530 | @if (\$isCreateModalOpen)
531 |
532 |
533 |
534 | {$_['createModalDescription']}
535 |
536 |
537 | {$formFields}
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 | @endif
548 |
549 | @if (\$isDeleteModalOpen)
550 |
551 | {$_['deleteModalDescription']}
552 |
553 |
554 |
555 |
556 |
557 |
558 | @endif
559 |
560 | EOT;
561 | }
562 |
563 | /**
564 | * @throws FileNotFoundException
565 | */
566 | private function updateRoute(string $tableName, string $viewName): string
567 | {
568 | $webRouteContent = File::get(base_path('routes/web.php'));
569 | $uri = str($tableName)->kebab();
570 |
571 | $viewName = str_replace('/', '.', $viewName);
572 | $route = "Volt::route('/{$uri}', '{$viewName}');";
573 |
574 | if (!str($webRouteContent)->contains($route)) {
575 | File::put(base_path('routes/web.php'), str($webRouteContent)->append("\r\n")->append($route));
576 | }
577 |
578 | return $uri;
579 | }
580 |
581 | private function createLivewireFile(string $content, string $filePath): void
582 | {
583 | $this->createFile($filePath, $content);
584 | }
585 |
586 | private function createFile(string $filePath, string $content = ''): bool
587 | {
588 | $pathInfo = pathinfo($filePath);
589 |
590 | $dirPath = $pathInfo['dirname'];
591 |
592 | if (!is_dir($dirPath)) {
593 | mkdir($dirPath, 0755, true);
594 | }
595 |
596 | if (file_put_contents($filePath, $content) !== false) {
597 | return true;
598 | }
599 |
600 | return false;
601 | }
602 | }
603 |
--------------------------------------------------------------------------------