Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from prateekkarki/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
prateekkarki authored Feb 14, 2019
2 parents e2e0f62 + adc2067 commit 2061ae3
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Generators/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getForeignMethods()
$foreignMethods .= $this->buildTemplate('Model-parent', [
'{{parent}}' => str_singular($parent),
'{{columnName}}' => str_singular($column),
'{{parentModel}}' => ucfirst(camel_case(str_singular($parent)))
'{{parentModel}}' => ($parent == 'users' && class_exists('\\App\\User')) ? "\\App\\User" : ucfirst(camel_case(str_singular($parent)))
]);
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Generators/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class View extends BaseGenerator implements GeneratorInterface
{
public function generate()
{
$viewsToBeGenerated = ['index', '_list', '_show', '_empty']; // To be generated dynamically
$viewsToBeGenerated = ['index', 'show', '_list', '_show', '_empty']; // To be generated dynamically

$generatedFiles = [];
foreach ($viewsToBeGenerated as $view) {
Expand All @@ -19,8 +19,17 @@ public function generate()

$fullFilePath = $this->getPath("resources/views/" . $this->module->getModuleName()) . "/{$view}.blade.php";
file_put_contents($fullFilePath, $viewTemplate);
$generatedFiles[] = $fullFilePath;
$generatedFiles[] = $fullFilePath;
}

$layoutPath = $this->getPath("resources/views/laragen/layouts/") . "app.blade.php";
if(!file_exists($layoutPath)){

$viewTemplate = $this->buildTemplate('Views/layouts/app', []);
file_put_contents($layoutPath, $viewTemplate);
$generatedFiles[] = $layoutPath;
}

return $generatedFiles;
}
}
4 changes: 2 additions & 2 deletions src/resources/stubs/Views/_show.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@endif
<div class="{{modelNameSingularLowercase}}-grid-info">
<h3>
<a href="{{ route('{{moduleName}}.show', ['slug' => ${{modelNameSingularLowercase}}->slug]) }}">
<a href="{{ route('{{moduleName}}.show', ${{modelNameSingularLowercase}}) }}">
{{ ${{modelNameSingularLowercase}}->title }}
</a>
</h3>
Expand All @@ -21,7 +21,7 @@
{{ ${{modelNameSingularLowercase}}->content }}
</p>

<a href="{{ route('{{moduleName}}.show', ['slug' => ${{modelNameSingularLowercase}}->slug]) }}">
<a href="{{ route('{{moduleName}}.show', ${{modelNameSingularLowercase}}) }}">
Read More
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/resources/stubs/Views/index.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('layouts.app')
@extends('laragen.layouts.app')

@section('content')

Expand Down
39 changes: 39 additions & 0 deletions src/resources/stubs/Views/layouts/app.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
@auth
<meta name="api-token" content="{{ auth()->user()->api_token }}">
@endauth

<title>{{ config('app.name', 'Laravel') }}</title>


<!-- Styles -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href="{{ asset('css/style.css') }}" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<div id="app">
<div class="wrap">
<div class="header">
<div class="logo">
<a href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
</div>
</div>
</div>

@yield('content')

</div>

@stack('inline-scripts')
</body>
</html>
8 changes: 4 additions & 4 deletions src/resources/stubs/Views/show.stub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@extends('layouts.app')
@extends('laragen.layouts.app')

@section('content')

Expand All @@ -14,7 +14,7 @@

<div class="{{modelNameSingularLowercase}}-grid-info">
<h3>
<a href="{{ route('{{moduleName}}.show', ['slug' => ${{modelNameSingularLowercase}}->slug]) }}">
<a href="{{ route('{{moduleName}}.show', ${{modelNameSingularLowercase}}) }}">
{{ ${{modelNameSingularLowercase}}->title }}
</a>
</h3>
Expand All @@ -23,8 +23,8 @@
{{ ${{modelNameSingularLowercase}}->content }}
</p>

<a href="{{ route('{{moduleName}}.show', ['slug' => ${{modelNameSingularLowercase}}->slug]) }}">
Read More
<a href="{{ route('{{moduleName}}.index') }}">
Back to {{moduleName}}
</a>
</div>
</div>
Expand Down

0 comments on commit 2061ae3

Please sign in to comment.