app/Http/Controllers/Admin/RouteController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(StoreRouteRequest $request)
    {
        foreach ($request->routes as $key => $route) {
            $routes[$route] = [
                'order' => $key,
                'minutes_from_departure' => $request->travel_time[$key - 1] ?? null,
                'distance_from_departure' => $request->distance[$key - 1] ?? null,
            ];
        }
        $route = Auth::user()->company()->routes()->create($request->only(['route_name']));
        $route->terminals()->attach($routes);
        return redirect()->route('admin.routes.index')
            ->with('success', 'Route created successfully.');
    }
public function store ( StoreRouteRequest $ request ) { foreach ( $ request -> routes as $ key => $ route ) { $ routes [ $ route ] = [ 'order' => $ key , 'minutes_from_departure' => $ request -> travel_time [ $ key - 1 ] ?? null , 'distance_from_departure' => $ request -> distance [ $ key - 1 ] ?? null , ] ; } $ route = Auth :: user ( ) -> company ( ) -> routes ( ) -> create ( $ request -> only ( [ 'route_name' ] ) ) ; $ route -> terminals ( ) -> attach ( $ routes ) ; return redirect ( ) -> route ( 'admin.routes.index' ) -> with ( 'success' , 'Route created successfully.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//