use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class {{studly_case($migration_name)}} extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('{{$table_name}}', function (Blueprint $table) { $table->increments('id'); @foreach($fields as $key => $value) @if($value['dbfield'] == "") @continue @endif @if(strpos($value["validation"],"unique")) @if(strpos($value["dbfield"],",")) $table->{!! (@explode(',', $value["dbfield_type"] )[0]=='' ? "text" : @explode(',', $value["dbfield_type"] )[0]) !!}('{!! explode(',', $value["dbfield"] )[0] !!}')->unique()->nullable(); $table->{!! (@explode(',', $value["dbfield_type"] )[1]=='' ? "text" : @explode(',', $value["dbfield_type"] )[1]) !!}('{!! explode(',', $value["dbfield"] )[1] !!}')->unique()->nullable(); @else $table->{!! ($value["dbfield_type"]=='' ? "string" : $value["dbfield_type"]) !!}('{!! $value["dbfield"] !!}')->unique()->nullable(); @endif @elseif(str_contains($value["validation"],"required")) @if(strpos($value["dbfield"],",")) $table->{!! (@explode(',', $value["dbfield_type"] )[0]=='' ? "text" : @explode(',', $value["dbfield_type"] )[0]) !!}('{!! explode(',', $value["dbfield"] )[0] !!}'); $table->{!! (@explode(',', $value["dbfield_type"] )[1]=='' ? "text" : @explode(',', $value["dbfield_type"] )[1]) !!}('{!! explode(',', $value["dbfield"] )[1] !!}'); @else $table->{!! ($value["dbfield_type"]=='' ? "string" : $value["dbfield_type"]) !!}('{!! $value["dbfield"] !!}'); @endif @else @if(strpos($value["dbfield"],",")) $table->{!! (@explode(',', $value["dbfield_type"] )[0]=='' ? "text" : @explode(',', $value["dbfield_type"] )[0]) !!}('{!! explode(',', $value["dbfield"] )[0] !!}')->nullable(); $table->{!! (@explode(',', $value["dbfield_type"] )[1]=='' ? "text" : @explode(',', $value["dbfield_type"] )[1]) !!}('{!! explode(',', $value["dbfield"] )[1] !!}')->nullable(); @else $table->{!! ($value["dbfield_type"]=='' ? "string" : $value["dbfield_type"]) !!}('{!! $value["dbfield"] !!}')->nullable(); @endif @endif @endforeach $table->integer('created_by'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('{{ $table_name }}'); } }