Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: summerblue/generator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8.0.1
Choose a base ref
...
head repository: summerblue/generator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 5 commits
  • 16 files changed
  • 1 contributor

Commits on Dec 18, 2020

  1. seed default content

    summerblue committed Dec 18, 2020
    Copy the full SHA
    15565c6 View commit details

Commits on Mar 6, 2022

  1. for 9.x

    summerblue committed Mar 6, 2022
    Copy the full SHA
    6e5a9d1 View commit details
  2. update readme

    summerblue committed Mar 6, 2022
    Copy the full SHA
    c5b0fe9 View commit details
  3. update migration stub

    summerblue committed Mar 6, 2022
    Copy the full SHA
    7db1af9 View commit details
  4. add bootstrap 5 support

    summerblue committed Mar 6, 2022
    Copy the full SHA
    bfa995c View commit details
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -20,11 +20,11 @@
}
],
"require": {
"php": ">=7.0.0"
"php": ">=8.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3.3",
"laravel/laravel": "8.*"
"laravel/laravel": "9.*"
},
"autoload": {
"psr-4": {
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,12 @@ Laravel Scaffold Generator, for Laravel 5.3.

### Step 1: Install Through Composer

9.x:

```
composer require "summerblue/generator:9.*" --dev
```

8.x:

```
4 changes: 2 additions & 2 deletions src/Commands/ScaffoldMakeCommand.php
Original file line number Diff line number Diff line change
@@ -260,8 +260,8 @@ protected function getOptions()
'ui',
'ui',
InputOption::VALUE_OPTIONAL,
'UI Framework to generate scaffold. (Default bs4 - bootstrap 4)',
'bs4'
'UI Framework to generate scaffold. (Default bs5 - bootstrap 5)',
'bs5'
],
[
'validator',
4 changes: 2 additions & 2 deletions src/Stubs/migration.stub
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class {{ModelMigration}} extends Migration
return new class extends Migration
{
public function up()
{
@@ -15,4 +15,4 @@ class {{ModelMigration}} extends Migration
{
{{schema_down}}
}
}
};
9 changes: 1 addition & 8 deletions src/Stubs/seed.stub
Original file line number Diff line number Diff line change
@@ -9,14 +9,7 @@ class {{Models}}TableSeeder extends Seeder
{
public function run()
{
${{models}} = factory({{Model}}::class)->times(50)->make()->each(function (${{model}}, $index) {
if ($index == 0) {
// ${{model}}->field = 'value';
}
});

{{Model}}::insert(${{models}}->toArray());
{{Model}}::factory()->count(10)->create();
}

}

10 changes: 10 additions & 0 deletions src/Stubs/views/bs5/error.blade.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@if (count($errors) > 0)
<div class="alert alert-danger">
<div class="mt-2"><b>有错误发生:</b></div>
<ul class="mt-2 mb-2">
@foreach ($errors->all() as $error)
<li><i class="glyphicon glyphicon-remove"></i> {{ $error }}</li>
@endforeach
</ul>
</div>
@endif
1 change: 1 addition & 0 deletions src/Stubs/views/bs5/fields/content/default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<td>{{${{model}}->{{field.name}}}}</td>
5 changes: 5 additions & 0 deletions src/Stubs/views/bs5/fields/fillable/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="mb-3">
<label for="{{field.name}}-field">{{field.Name}}</label>
<input class="form-control" type="text" name="{{field.name}}" id="{{field.name}}-field" value="{{ old('{{field.name}}', ${{model}}->{{field.name}} ) }}" />
</div>
5 changes: 5 additions & 0 deletions src/Stubs/views/bs5/fields/fillable/string
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="mb-3">
<label for="{{field.name}}-field">{{field.Name}}</label>
<input class="form-control" type="text" name="{{field.name}}" id="{{field.name}}-field" value="{{ old('{{field.name}}', ${{model}}->{{field.name}} ) }}" />
</div>
5 changes: 5 additions & 0 deletions src/Stubs/views/bs5/fields/fillable/text
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="mb-3">
<label for="{{field.name}}-field">{{field.Name}}</label>
<textarea name="{{field.name}}" id="{{field.name}}-field" class="form-control" rows="3">{{ old('{{field.name}}', ${{model}}->{{field.name}} ) }}</textarea>
</div>
1 change: 1 addition & 0 deletions src/Stubs/views/bs5/fields/header/default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<th>{{field.Name}}</th>
4 changes: 4 additions & 0 deletions src/Stubs/views/bs5/fields/show/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<label>{{field.Name}}</label>
<p>
{{ ${{model}}->{{field.name}} }}
</p>
63 changes: 63 additions & 0 deletions src/Stubs/views/bs5/layout.blade.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">

<title>Starter Template</title>

<!-- META TAGs -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">

<!-- CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

@yield('css')
</head>

<body>

<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-static-top" style="margin-bottom:40px;border-bottom:1px solid #dfdfdf;">
<div class="container">
<a class="navbar-brand " href="{{ url('/') }}">
Project name
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="{{route('{{models}}.index')}}">{{Model}}</a></li>
</ul>
</div>
</div>
</nav>

<div class="container">
@if(session('message'))
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{{@session('message')}}
</div>
@endif

@yield('header')
@yield('content')
</div>

<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

@yield('scripts')
</body>

</html>
44 changes: 44 additions & 0 deletions src/Stubs/views/bs5/pages/create_and_edit.blade.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@extends('layouts.app')

@section('content')

<div class="container">
<div class="col-md-10 offset-md-1">
<div class="card ">

<div class="card-header">
<h1>
{{Model}} /
@if(${{model}}->id)
Edit #{{ ${{model}}->id }}
@else
Create
@endif
</h1>
</div>

<div class="card-body">
@if(${{model}}->id)
<form action="{{ route('{{prefix}}{{models}}.update', ${{model}}->id) }}" method="POST" accept-charset="UTF-8">
<input type="hidden" name="_method" value="PUT">
@else
<form action="{{ route('{{prefix}}{{models}}.store') }}" method="POST" accept-charset="UTF-8">
@endif

@include('common.error')

<input type="hidden" name="_token" value="{{ csrf_token() }}">

{{form_fields_fillable}}

<div class="well well-sm">
<button type="submit" class="btn btn-primary">Save</button>
<a class="btn btn-link float-xs-right" href="{{ route('{{prefix}}{{models}}.index') }}"> <- Back</a>
</div>
</form>
</div>
</div>
</div>
</div>

@endsection
61 changes: 61 additions & 0 deletions src/Stubs/views/bs5/pages/index.blade.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@extends('layouts.app')

@section('content')
<div class="container">
<div class="col-md-10 offset-md-1">
<div class="card ">
<div class="card-header">
<h1>
{{Model}}
<a class="btn btn-success float-xs-right" href="{{ route('{{prefix}}{{models}}.create') }}">Create</a>
</h1>
</div>

<div class="card-body">
@if(${{models}}->count())
<table class="table table-sm table-striped">
<thead>
<tr>
<th class="text-xs-center">#</th>
{{table_fields_header}}
<th class="text-xs-right">OPTIONS</th>
</tr>
</thead>

<tbody>
@foreach(${{models}} as ${{model}})
<tr>
<td class="text-xs-center"><strong>{{${{model}}->id}}</strong></td>

{{table_fields_content}}

<td class="text-xs-right">
<a class="btn btn-sm btn-primary" href="{{ route('{{prefix}}{{models}}.show', ${{model}}->id) }}">
V
</a>

<a class="btn btn-sm btn-warning" href="{{ route('{{prefix}}{{models}}.edit', ${{model}}->id) }}">
E
</a>

<form action="{{ route('{{prefix}}{{models}}.destroy', ${{model}}->id) }}" method="POST" style="display: inline;" onsubmit="return confirm('Delete? Are you sure?');">
{{csrf_field()}}
<input type="hidden" name="_method" value="DELETE">

<button type="submit" class="btn btn-sm btn-danger">D </button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
{!! ${{models}}->render() !!}
@else
<h3 class="text-xs-center alert alert-info">Empty!</h3>
@endif
</div>
</div>
</div>
</div>

@endsection
33 changes: 33 additions & 0 deletions src/Stubs/views/bs5/pages/show.blade.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@extends('layouts.app')

@section('content')

<div class="container">
<div class="col-md-10 offset-md-1">
<div class="card ">
<div class="card-header">
<h1>{{Model}} / Show #{{ ${{model}}->id }}</h1>
</div>

<div class="card-body">
<div class="card-block bg-light">
<div class="row">
<div class="col-md-6">
<a class="btn btn-link" href="{{ route('{{prefix}}{{models}}.index') }}"><- Back</a>
</div>
<div class="col-md-6">
<a class="btn btn-sm btn-warning float-right mt-1" href="{{ route('{{prefix}}{{models}}.edit', ${{model}}->id) }}">
Edit
</a>
</div>
</div>
</div>
<br>

{{form_fields_show}}
</div>
</div>
</div>
</div>

@endsection