Skip to content

Commit

Permalink
bs4
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Dec 23, 2018
1 parent 0c86760 commit 3308602
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Stubs/views/bs4/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/bs4/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/bs4/fields/fillable/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="form-group">
<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/bs4/fields/fillable/string
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="form-group">
<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/bs4/fields/fillable/text
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<div class="form-group">
<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/bs4/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/bs4/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/bs4/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-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/bs4/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/bs4/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/bs4/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

0 comments on commit 3308602

Please sign in to comment.