Skip to content

Commit 87af989

Browse files
committed
Updated to 0.3.0 and added foreignId data type in generator
1 parent b9cff8f commit 87af989

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Changelog
22

3-
**All notable changes to `AdminR` will be documented in this file**
3+
==================================================
44

5+
## Release v0.3.0 - Jun 21, 2022
56

6-
==================================================
7+
- Added ```foreignId``` data type.
78

9+
==================================================
810
## Release v0.2.5 - May 02, 2022
911

1012
- Added Default mail templates.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# AdminR v0.2.5
1+
# AdminR v0.3.0
22

33
<p align="center">
4-
<a href="https://travis-ci.org/thedevsbuddy/adminr"><img src="https://travis-ci.org/thedevsbuddy/adminr.svg" alt="Build Status"></a>
54
<a href="https://packagist.org/packages/thedevsbuddy/adminr"><img src="https://img.shields.io/packagist/dt/thedevsbuddy/adminr" alt="Total Downloads"></a>
65
<a href="https://packagist.org/packages/thedevsbuddy/adminr"><img src="https://img.shields.io/packagist/v/thedevsbuddy/adminr" alt="Latest Stable Version"></a>
76
<a href="https://packagist.org/packages/thedevsbuddy/adminr"><img src="https://img.shields.io/packagist/l/thedevsbuddy/adminr" alt="License"></a>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="{{COL_SM}} {{COL_MD}} {{COL_LG}}">
22
<div class="form-group has-feedback @if($errors->has('{{FIELD_NAME}}')) has-error @endif">
33
<label for="{{FIELD_NAME}}">{{FIELD_NAME_LABEL}}</label>
4-
<select name="{{FIELD_NAME}}" id="{{FIELD_NAME}}" class="form-control @if($errors->has('{{FIELD_NAME}}')) is-invalid @endif" placeholder="{{FIELD_NAME_LABEL}}" {{REQUIRED_STATEMENT}}>
4+
<select name="{{FIELD_NAME}}" id="{{FIELD_NAME}}" class="form-control @if($errors->has('{{FIELD_NAME}}')) is-invalid @endif" {{REQUIRED_STATEMENT}}>
55
{{OPTIONS_STATEMENT}}
66
</select>
77
@if ($errors->has('{{FIELD_NAME}}'))
@@ -10,4 +10,4 @@
1010
</span>
1111
@endif
1212
</div>
13-
</div>
13+
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="{{COL_SM}} {{COL_MD}} {{COL_LG}}">
22
<div class="form-group has-feedback @if($errors->has('{{FIELD_NAME}}')) has-error @endif">
33
<label for="{{FIELD_NAME}}">{{FIELD_NAME_LABEL}}</label>
4-
<select name="{{FIELD_NAME}}" id="{{FIELD_NAME}}" class="form-control @if($errors->has('{{FIELD_NAME}}')) is-invalid @endif" placeholder="{{FIELD_NAME_LABEL}}" {{REQUIRED_STATEMENT}}>
4+
<select name="{{FIELD_NAME}}" id="{{FIELD_NAME}}" class="form-control @if($errors->has('{{FIELD_NAME}}')) is-invalid @endif" {{REQUIRED_STATEMENT}}>
55
{{OPTIONS_STATEMENT}}
66
</select>
77
@if ($errors->has('{{FIELD_NAME}}'))
@@ -10,4 +10,4 @@
1010
</span>
1111
@endif
1212
</div>
13-
</div>
13+
</div>

app/adminr-engine/src/Services/BuildViewsService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,19 @@ private function getOldFileStatement(): string
206206
return $oldFileStmt;
207207
}
208208

209-
#[Pure] private function getOptionsStmt($migration): string
209+
private function getOptionsStmt($migration): string
210210
{
211211
$optionsStmt = "";
212212
if($migration['data_type'] == 'enum'){
213213
$optionsStmt .= "<option value=\"\">--Select ".Str::title($migration['field_name'])."--</option>\n\t\t";
214214
foreach (preg_split('/[,\s?]+/', $migration['enum_values']) as $val){
215215
$optionsStmt .= "<option value=\"".strtolower($val)."\">".Str::title($val)."</option>\n\t\t";
216216
}
217+
} else if($migration['data_type'] == 'foreignId'){
218+
$optionsStmt .= "<option value=\"\">--Select ".Str::title($migration['related_model'])."--</option>\n\t\t\t\t\t\t\t\t\t\t";
219+
$optionsStmt .= "@foreach($".Str::camel(Str::plural($migration['related_model']))." as \$index => $".Str::camel(Str::singular($migration['related_model'])).")\n\t\t\t\t\t\t\t\t\t\t\t";
220+
$optionsStmt .= "<option value=\"{{\$".Str::camel(Str::singular($migration['related_model']))."->id}}\">{{\$".Str::camel(Str::singular($migration['related_model']))."->".Str::snake($migration['related_model_label'])."}}</option>\n\t\t\t\t\t\t\t\t\t\t";
221+
$optionsStmt .= "@endforeach";
217222
}
218223

219224
return $optionsStmt;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thedevsbuddy/adminr",
3-
"version": "0.2.5",
3+
"version": "0.3.0",
44
"type": "project",
55
"description": "A simple yet powerful laravel starter with admin panel and CRUD resources generator to help you build application faster.",
66
"keywords": [

0 commit comments

Comments
 (0)