Guest User

Untitled

a guest
Jul 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public function create($id)
  2. {
  3. $type = Type::find($id);
  4. $category = Category::all();
  5. foreach ($type->field as $key => $value) {
  6. if (Schema::hasColumn('products', "{$value->fieldname}")) {
  7.  
  8. return view('products.create', compact('type', 'category'));
  9. } else
  10. {if (!Schema::hasColumn('products', "{$value->fieldname}")) {
  11. foreach ($type->field as $key => $value) {
  12. Schema::table('products', function ($table) use ($value) {
  13. $table->string("{$value->fieldname}")->nullable()-> after('category_id');
  14. });
  15. }
  16.  
  17. return view('products.create', compact('type', 'category'));
  18. }
  19.  
  20. }
  21.  
  22. }
  23. }
Add Comment
Please, Sign In to add comment