public function store($payload)
    {
        $payload['external'] = isset($payload['external']) ? $payload['external'] : 0;

        if ($payload['external'] != 0 && empty($payload['external_url'])) {
            throw new Exception("Your link was missing a URL", 1);
        }

        if (!isset($payload['page_id'])) {
            $payload['page_id'] = 0;
        }

        if ($payload['page_id'] == 0 && $payload['external'] == 0) {
            throw new Exception("Your link was not connected to anything, and could not be made", 1);
        }

        $link = $this->model->create($payload);

        $order = json_decode($link->menu->order);
        array_push($order, $link->id);
        $link->menu->update([
            'order' => json_encode($order),
        ]);

        return $link;
    }
public function store($payload)
    {
        $payload['external'] = isset($payload['external']) ? $payload['external'] : 0;

        if ($payload['external'] != 0 && empty($payload['external_url'])) {
            throw new Exception("Your link was missing a URL", 1);
        }

        if (!isset($payload['page_id'])) {
            $payload['page_id'] = 0;
        }

        if ($payload['page_id'] == 0 && $payload['external'] == 0) {
            throw new Exception("Your link was not connected to anything, and could not be made", 1);
        }

        $link = $this->model->create($payload);

        $order = json_decode($link->menu->order);
        array_push($order, $link->id);
        $link->menu->update([
            'order' => json_encode($order),
        ]);

        return $link;
    }
public function store ( $ payload ) { $ payload [ 'external' ] = isset ( $ payload [ 'external' ] ) ? $ payload [ 'external' ] : 0 ; if ( $ payload [ 'external' ] != 0 && empty ( $ payload [ 'external_url' ] ) ) { throw new Exception ( "Your link was missing a URL" , 1 ) ; } if ( ! isset ( $ payload [ 'page_id' ] ) ) { $ payload [ 'page_id' ] = 0 ; } if ( $ payload [ 'page_id' ] == 0 && $ payload [ 'external' ] == 0 ) { throw new Exception ( "Your link was not connected to anything, and could not be made" , 1 ) ; } $ link = $ this -> model -> create ( $ payload ) ; $ order = json_decode ( $ link -> menu -> order ) ; array_push ( $ order , $ link -> id ) ; $ link -> menu -> update ( [ 'order' => json_encode ( $ order ) , ] ) ; return $ link ; }
Stores Links into database.

@param array $payload

@return Links
Stores Links into database .