Xử lý vòng lặp @for trong laravel

Mình có 1 form như thế này:

Form này tạo ra 1 view trong thư mục resource.

Mình lấy dữ liệu trên form này đổ ra trang web của người dùng. Trong AppServiceProvider mình chia sẻ dữ liệu cho toàn view

public function boot()
{
    Schema::defaultStringLength(191);
    $menus = MenuDirection::whereNull('nameRoot')->get();
    $modules = Modules::orderBy('order','ASC')->get();
    view()->share('menus',$menus);
    view()->share('modules',$modules);
}

Trong view app và view about_page mình duyệt 2 vòng lặp for. 1 vòng lặp trên view app và 1 vòng lặp trên view about_page. Nếu đúng tên view thì include nó vào

Trong view ‘app.blade.php’

@foreach($modules as $module)
    	@if($module->name == 'footer' || $module->name == 'modal')
    		@include('user.'.$module->name)
    	@endif
    @endforeach

Trong view ‘about_page.blade.php’

@extends('user.layouts.app')
@section('main')
	@foreach($modules as $module)
    	@if($module->name == 'banner' || $module->name == 'about' || $module->name=='stats' || $module->name == 'about_main')
    		@include('user.'.$module->name)
    	@endif
    @endforeach
@stop

Mình đã tạo modules dựa theo cấu trúc có sẵn như thế này:

Giả sử như mình muốn thêm 1 modules mới không theo template này để show lên trang người dùng thì phải kiểm tra điều kiện như thế nào? Mọi người giúp mình với! Mình cám ơn nhiều :slight_smile:

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?